<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE GADTs #-}</span><span>
</span><span id="line-2"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Cmm.Sink</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-3"></span><span>     </span><span class="annot"><a href="GHC.Cmm.Sink.html#cmmSink"><span class="hs-identifier">cmmSink</span></a></span><span>
</span><span id="line-4"></span><span>  </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-5"></span><span>
</span><span id="line-6"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-7"></span><span>
</span><span id="line-8"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.html"><span class="hs-identifier">GHC.Cmm</span></a></span><span>
</span><span id="line-9"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.Opt.html"><span class="hs-identifier">GHC.Cmm.Opt</span></a></span><span>
</span><span id="line-10"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.Liveness.html"><span class="hs-identifier">GHC.Cmm.Liveness</span></a></span><span>
</span><span id="line-11"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.Utils.html"><span class="hs-identifier">GHC.Cmm.Utils</span></a></span><span>
</span><span id="line-12"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Block.html"><span class="hs-identifier">GHC.Cmm.Dataflow.Block</span></a></span><span>
</span><span id="line-13"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html"><span class="hs-identifier">GHC.Cmm.Dataflow.Label</span></a></span><span>
</span><span id="line-14"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Collections.html"><span class="hs-identifier">GHC.Cmm.Dataflow.Collections</span></a></span><span>
</span><span id="line-15"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Graph.html"><span class="hs-identifier">GHC.Cmm.Dataflow.Graph</span></a></span><span>
</span><span id="line-16"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Platform.Regs.html"><span class="hs-identifier">GHC.Platform.Regs</span></a></span><span>
</span><span id="line-17"></span><span>
</span><span id="line-18"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#"><span class="hs-identifier">GHC.Platform</span></a></span><span>
</span><span id="line-19"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html"><span class="hs-identifier">GHC.Driver.Session</span></a></span><span>
</span><span id="line-20"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Unique.html"><span class="hs-identifier">GHC.Types.Unique</span></a></span><span>
</span><span id="line-21"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Unique.FM.html"><span class="hs-identifier">GHC.Types.Unique.FM</span></a></span><span>
</span><span id="line-22"></span><span>
</span><span id="line-23"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../containers/src/Data.IntSet.html#"><span class="hs-identifier">Data.IntSet</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">IntSet</span></span><span>
</span><span id="line-24"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.List.html#"><span class="hs-identifier">Data.List</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.OldList.html#partition"><span class="hs-identifier">partition</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-25"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../containers/src/Data.Set.html#"><span class="hs-identifier">Data.Set</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Set</span></span><span>
</span><span id="line-26"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Maybe.html#"><span class="hs-identifier">Data.Maybe</span></a></span><span>
</span><span id="line-27"></span><span>
</span><span id="line-28"></span><span class="hs-comment">-- Compact sets for membership tests of local variables.</span><span>
</span><span id="line-29"></span><span>
</span><span id="line-30"></span><span class="hs-keyword">type</span><span> </span><span id="LRegSet"><span class="annot"><a href="GHC.Cmm.Sink.html#LRegSet"><span class="hs-identifier hs-var">LRegSet</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="../../containers/src/Data.IntSet.Internal.html#IntSet"><span class="hs-identifier hs-type">IntSet.IntSet</span></a></span><span>
</span><span id="line-31"></span><span>
</span><span id="line-32"></span><span class="annot"><a href="GHC.Cmm.Sink.html#emptyLRegSet"><span class="hs-identifier hs-type">emptyLRegSet</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Sink.html#LRegSet"><span class="hs-identifier hs-type">LRegSet</span></a></span><span>
</span><span id="line-33"></span><span id="emptyLRegSet"><span class="annot"><span class="annottext">emptyLRegSet :: LRegSet
</span><a href="GHC.Cmm.Sink.html#emptyLRegSet"><span class="hs-identifier hs-var hs-var">emptyLRegSet</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LRegSet
</span><a href="../../containers/src/Data.IntSet.Internal.html#empty"><span class="hs-identifier hs-var">IntSet.empty</span></a></span><span>
</span><span id="line-34"></span><span>
</span><span id="line-35"></span><span class="annot"><a href="GHC.Cmm.Sink.html#nullLRegSet"><span class="hs-identifier hs-type">nullLRegSet</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Sink.html#LRegSet"><span class="hs-identifier hs-type">LRegSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-36"></span><span id="nullLRegSet"><span class="annot"><span class="annottext">nullLRegSet :: LRegSet -&gt; Bool
</span><a href="GHC.Cmm.Sink.html#nullLRegSet"><span class="hs-identifier hs-var hs-var">nullLRegSet</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LRegSet -&gt; Bool
</span><a href="../../containers/src/Data.IntSet.Internal.html#null"><span class="hs-identifier hs-var">IntSet.null</span></a></span><span>
</span><span id="line-37"></span><span>
</span><span id="line-38"></span><span class="annot"><a href="GHC.Cmm.Sink.html#insertLRegSet"><span class="hs-identifier hs-type">insertLRegSet</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#LocalReg"><span class="hs-identifier hs-type">LocalReg</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Sink.html#LRegSet"><span class="hs-identifier hs-type">LRegSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Sink.html#LRegSet"><span class="hs-identifier hs-type">LRegSet</span></a></span><span>
</span><span id="line-39"></span><span id="insertLRegSet"><span class="annot"><span class="annottext">insertLRegSet :: LocalReg -&gt; LRegSet -&gt; LRegSet
</span><a href="GHC.Cmm.Sink.html#insertLRegSet"><span class="hs-identifier hs-var hs-var">insertLRegSet</span></a></span></span><span> </span><span id="local-6989586621681046359"><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681046359"><span class="hs-identifier hs-var">l</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; LRegSet -&gt; LRegSet
</span><a href="../../containers/src/Data.IntSet.Internal.html#insert"><span class="hs-identifier hs-var">IntSet.insert</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Unique -&gt; Int
</span><a href="GHC.Types.Unique.html#getKey"><span class="hs-identifier hs-var">getKey</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LocalReg -&gt; Unique
forall a. Uniquable a =&gt; a -&gt; Unique
</span><a href="GHC.Types.Unique.html#getUnique"><span class="hs-identifier hs-var">getUnique</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681046359"><span class="hs-identifier hs-var">l</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-40"></span><span>
</span><span id="line-41"></span><span class="annot"><a href="GHC.Cmm.Sink.html#elemLRegSet"><span class="hs-identifier hs-type">elemLRegSet</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#LocalReg"><span class="hs-identifier hs-type">LocalReg</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Sink.html#LRegSet"><span class="hs-identifier hs-type">LRegSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-42"></span><span id="elemLRegSet"><span class="annot"><span class="annottext">elemLRegSet :: LocalReg -&gt; LRegSet -&gt; Bool
</span><a href="GHC.Cmm.Sink.html#elemLRegSet"><span class="hs-identifier hs-var hs-var">elemLRegSet</span></a></span></span><span> </span><span id="local-6989586621681046354"><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681046354"><span class="hs-identifier hs-var">l</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; LRegSet -&gt; Bool
</span><a href="../../containers/src/Data.IntSet.Internal.html#member"><span class="hs-identifier hs-var">IntSet.member</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Unique -&gt; Int
</span><a href="GHC.Types.Unique.html#getKey"><span class="hs-identifier hs-var">getKey</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LocalReg -&gt; Unique
forall a. Uniquable a =&gt; a -&gt; Unique
</span><a href="GHC.Types.Unique.html#getUnique"><span class="hs-identifier hs-var">getUnique</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681046354"><span class="hs-identifier hs-var">l</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-43"></span><span>
</span><span id="line-44"></span><span class="hs-comment">-- -----------------------------------------------------------------------------</span><span>
</span><span id="line-45"></span><span class="hs-comment">-- Sinking and inlining</span><span>
</span><span id="line-46"></span><span>
</span><span id="line-47"></span><span class="hs-comment">-- This is an optimisation pass that</span><span>
</span><span id="line-48"></span><span class="hs-comment">--  (a) moves assignments closer to their uses, to reduce register pressure</span><span>
</span><span id="line-49"></span><span class="hs-comment">--  (b) pushes assignments into a single branch of a conditional if possible</span><span>
</span><span id="line-50"></span><span class="hs-comment">--  (c) inlines assignments to registers that are mentioned only once</span><span>
</span><span id="line-51"></span><span class="hs-comment">--  (d) discards dead assignments</span><span>
</span><span id="line-52"></span><span class="hs-comment">--</span><span>
</span><span id="line-53"></span><span class="hs-comment">-- This tightens up lots of register-heavy code.  It is particularly</span><span>
</span><span id="line-54"></span><span class="hs-comment">-- helpful in the Cmm generated by the Stg-&gt;Cmm code generator, in</span><span>
</span><span id="line-55"></span><span class="hs-comment">-- which every function starts with a copyIn sequence like:</span><span>
</span><span id="line-56"></span><span class="hs-comment">--</span><span>
</span><span id="line-57"></span><span class="hs-comment">--    x1 = R1</span><span>
</span><span id="line-58"></span><span class="hs-comment">--    x2 = Sp[8]</span><span>
</span><span id="line-59"></span><span class="hs-comment">--    x3 = Sp[16]</span><span>
</span><span id="line-60"></span><span class="hs-comment">--    if (Sp - 32 &lt; SpLim) then L1 else L2</span><span>
</span><span id="line-61"></span><span class="hs-comment">--</span><span>
</span><span id="line-62"></span><span class="hs-comment">-- we really want to push the x1..x3 assignments into the L2 branch.</span><span>
</span><span id="line-63"></span><span class="hs-comment">--</span><span>
</span><span id="line-64"></span><span class="hs-comment">-- Algorithm:</span><span>
</span><span id="line-65"></span><span class="hs-comment">--</span><span>
</span><span id="line-66"></span><span class="hs-comment">--  * Start by doing liveness analysis.</span><span>
</span><span id="line-67"></span><span class="hs-comment">--</span><span>
</span><span id="line-68"></span><span class="hs-comment">--  * Keep a list of assignments A; earlier ones may refer to later ones.</span><span>
</span><span id="line-69"></span><span class="hs-comment">--    Currently we only sink assignments to local registers, because we don't</span><span>
</span><span id="line-70"></span><span class="hs-comment">--    have liveness information about global registers.</span><span>
</span><span id="line-71"></span><span class="hs-comment">--</span><span>
</span><span id="line-72"></span><span class="hs-comment">--  * Walk forwards through the graph, look at each node N:</span><span>
</span><span id="line-73"></span><span class="hs-comment">--</span><span>
</span><span id="line-74"></span><span class="hs-comment">--    * If it is a dead assignment, i.e. assignment to a register that is</span><span>
</span><span id="line-75"></span><span class="hs-comment">--      not used after N, discard it.</span><span>
</span><span id="line-76"></span><span class="hs-comment">--</span><span>
</span><span id="line-77"></span><span class="hs-comment">--    * Try to inline based on current list of assignments</span><span>
</span><span id="line-78"></span><span class="hs-comment">--      * If any assignments in A (1) occur only once in N, and (2) are</span><span>
</span><span id="line-79"></span><span class="hs-comment">--        not live after N, inline the assignment and remove it</span><span>
</span><span id="line-80"></span><span class="hs-comment">--        from A.</span><span>
</span><span id="line-81"></span><span class="hs-comment">--</span><span>
</span><span id="line-82"></span><span class="hs-comment">--      * If an assignment in A is cheap (RHS is local register), then</span><span>
</span><span id="line-83"></span><span class="hs-comment">--        inline the assignment and keep it in A in case it is used afterwards.</span><span>
</span><span id="line-84"></span><span class="hs-comment">--</span><span>
</span><span id="line-85"></span><span class="hs-comment">--      * Otherwise don't inline.</span><span>
</span><span id="line-86"></span><span class="hs-comment">--</span><span>
</span><span id="line-87"></span><span class="hs-comment">--    * If N is assignment to a local register pick up the assignment</span><span>
</span><span id="line-88"></span><span class="hs-comment">--      and add it to A.</span><span>
</span><span id="line-89"></span><span class="hs-comment">--</span><span>
</span><span id="line-90"></span><span class="hs-comment">--    * If N is not an assignment to a local register:</span><span>
</span><span id="line-91"></span><span class="hs-comment">--      * remove any assignments from A that conflict with N, and</span><span>
</span><span id="line-92"></span><span class="hs-comment">--        place them before N in the current block.  We call this</span><span>
</span><span id="line-93"></span><span class="hs-comment">--        &quot;dropping&quot; the assignments.</span><span>
</span><span id="line-94"></span><span class="hs-comment">--</span><span>
</span><span id="line-95"></span><span class="hs-comment">--      * An assignment conflicts with N if it:</span><span>
</span><span id="line-96"></span><span class="hs-comment">--        - assigns to a register mentioned in N</span><span>
</span><span id="line-97"></span><span class="hs-comment">--        - mentions a register assigned by N</span><span>
</span><span id="line-98"></span><span class="hs-comment">--        - reads from memory written by N</span><span>
</span><span id="line-99"></span><span class="hs-comment">--      * do this recursively, dropping dependent assignments</span><span>
</span><span id="line-100"></span><span class="hs-comment">--</span><span>
</span><span id="line-101"></span><span class="hs-comment">--    * At an exit node:</span><span>
</span><span id="line-102"></span><span class="hs-comment">--      * drop any assignments that are live on more than one successor</span><span>
</span><span id="line-103"></span><span class="hs-comment">--        and are not trivial</span><span>
</span><span id="line-104"></span><span class="hs-comment">--      * if any successor has more than one predecessor (a join-point),</span><span>
</span><span id="line-105"></span><span class="hs-comment">--        drop everything live in that successor. Since we only propagate</span><span>
</span><span id="line-106"></span><span class="hs-comment">--        assignments that are not dead at the successor, we will therefore</span><span>
</span><span id="line-107"></span><span class="hs-comment">--        eliminate all assignments dead at this point. Thus analysis of a</span><span>
</span><span id="line-108"></span><span class="hs-comment">--        join-point will always begin with an empty list of assignments.</span><span>
</span><span id="line-109"></span><span class="hs-comment">--</span><span>
</span><span id="line-110"></span><span class="hs-comment">--</span><span>
</span><span id="line-111"></span><span class="hs-comment">-- As a result of above algorithm, sinking deletes some dead assignments</span><span>
</span><span id="line-112"></span><span class="hs-comment">-- (transitively, even).  This isn't as good as removeDeadAssignments,</span><span>
</span><span id="line-113"></span><span class="hs-comment">-- but it's much cheaper.</span><span>
</span><span id="line-114"></span><span>
</span><span id="line-115"></span><span class="hs-comment">-- -----------------------------------------------------------------------------</span><span>
</span><span id="line-116"></span><span class="hs-comment">-- things that we aren't optimising very well yet.</span><span>
</span><span id="line-117"></span><span class="hs-comment">--</span><span>
</span><span id="line-118"></span><span class="hs-comment">-- -----------</span><span>
</span><span id="line-119"></span><span class="hs-comment">-- (1) From GHC's FastString.hashStr:</span><span>
</span><span id="line-120"></span><span class="hs-comment">--</span><span>
</span><span id="line-121"></span><span class="hs-comment">--  s2ay:</span><span>
</span><span id="line-122"></span><span class="hs-comment">--      if ((_s2an::I64 == _s2ao::I64) &gt;= 1) goto c2gn; else goto c2gp;</span><span>
</span><span id="line-123"></span><span class="hs-comment">--  c2gn:</span><span>
</span><span id="line-124"></span><span class="hs-comment">--      R1 = _s2au::I64;</span><span>
</span><span id="line-125"></span><span class="hs-comment">--      call (I64[Sp])(R1) args: 8, res: 0, upd: 8;</span><span>
</span><span id="line-126"></span><span class="hs-comment">--  c2gp:</span><span>
</span><span id="line-127"></span><span class="hs-comment">--      _s2cO::I64 = %MO_S_Rem_W64(%MO_UU_Conv_W8_W64(I8[_s2aq::I64 + (_s2an::I64 &lt;&lt; 0)]) + _s2au::I64 * 128,</span><span>
</span><span id="line-128"></span><span class="hs-comment">--                                 4091);</span><span>
</span><span id="line-129"></span><span class="hs-comment">--      _s2an::I64 = _s2an::I64 + 1;</span><span>
</span><span id="line-130"></span><span class="hs-comment">--      _s2au::I64 = _s2cO::I64;</span><span>
</span><span id="line-131"></span><span class="hs-comment">--      goto s2ay;</span><span>
</span><span id="line-132"></span><span class="hs-comment">--</span><span>
</span><span id="line-133"></span><span class="hs-comment">-- a nice loop, but we didn't eliminate the silly assignment at the end.</span><span>
</span><span id="line-134"></span><span class="hs-comment">-- See Note [dependent assignments], which would probably fix this.</span><span>
</span><span id="line-135"></span><span class="hs-comment">-- This is #8336.</span><span>
</span><span id="line-136"></span><span class="hs-comment">--</span><span>
</span><span id="line-137"></span><span class="hs-comment">-- -----------</span><span>
</span><span id="line-138"></span><span class="hs-comment">-- (2) From stg_atomically_frame in PrimOps.cmm</span><span>
</span><span id="line-139"></span><span class="hs-comment">--</span><span>
</span><span id="line-140"></span><span class="hs-comment">-- We have a diamond control flow:</span><span>
</span><span id="line-141"></span><span class="hs-comment">--</span><span>
</span><span id="line-142"></span><span class="hs-comment">--     x = ...</span><span>
</span><span id="line-143"></span><span class="hs-comment">--       |</span><span>
</span><span id="line-144"></span><span class="hs-comment">--      / \</span><span>
</span><span id="line-145"></span><span class="hs-comment">--     A   B</span><span>
</span><span id="line-146"></span><span class="hs-comment">--      \ /</span><span>
</span><span id="line-147"></span><span class="hs-comment">--       |</span><span>
</span><span id="line-148"></span><span class="hs-comment">--    use of x</span><span>
</span><span id="line-149"></span><span class="hs-comment">--</span><span>
</span><span id="line-150"></span><span class="hs-comment">-- Now x won't be sunk down to its use, because we won't push it into</span><span>
</span><span id="line-151"></span><span class="hs-comment">-- both branches of the conditional.  We certainly do have to check</span><span>
</span><span id="line-152"></span><span class="hs-comment">-- that we can sink it past all the code in both A and B, but having</span><span>
</span><span id="line-153"></span><span class="hs-comment">-- discovered that, we could sink it to its use.</span><span>
</span><span id="line-154"></span><span class="hs-comment">--</span><span>
</span><span id="line-155"></span><span>
</span><span id="line-156"></span><span class="hs-comment">-- -----------------------------------------------------------------------------</span><span>
</span><span id="line-157"></span><span>
</span><span id="line-158"></span><span class="hs-keyword">type</span><span> </span><span id="Assignment"><span class="annot"><a href="GHC.Cmm.Sink.html#Assignment"><span class="hs-identifier hs-var">Assignment</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Expr.html#LocalReg"><span class="hs-identifier hs-type">LocalReg</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Cmm.Sink.html#AbsMem"><span class="hs-identifier hs-type">AbsMem</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-159"></span><span>  </span><span class="hs-comment">-- Assignment caches AbsMem, an abstraction of the memory read by</span><span>
</span><span id="line-160"></span><span>  </span><span class="hs-comment">-- the RHS of the assignment.</span><span>
</span><span id="line-161"></span><span>
</span><span id="line-162"></span><span class="hs-keyword">type</span><span> </span><span id="Assignments"><span class="annot"><a href="GHC.Cmm.Sink.html#Assignments"><span class="hs-identifier hs-var">Assignments</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.Sink.html#Assignment"><span class="hs-identifier hs-type">Assignment</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-163"></span><span>  </span><span class="hs-comment">-- A sequence of assignments; kept in *reverse* order</span><span>
</span><span id="line-164"></span><span>  </span><span class="hs-comment">-- So the list [ x=e1, y=e2 ] means the sequence of assignments</span><span>
</span><span id="line-165"></span><span>  </span><span class="hs-comment">--     y = e2</span><span>
</span><span id="line-166"></span><span>  </span><span class="hs-comment">--     x = e1</span><span>
</span><span id="line-167"></span><span>
</span><span id="line-168"></span><span class="annot"><a href="GHC.Cmm.Sink.html#cmmSink"><span class="hs-identifier hs-type">cmmSink</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.html#CmmGraph"><span class="hs-identifier hs-type">CmmGraph</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.html#CmmGraph"><span class="hs-identifier hs-type">CmmGraph</span></a></span><span>
</span><span id="line-169"></span><span id="cmmSink"><span class="annot"><span class="annottext">cmmSink :: DynFlags -&gt; CmmGraph -&gt; CmmGraph
</span><a href="GHC.Cmm.Sink.html#cmmSink"><span class="hs-identifier hs-var hs-var">cmmSink</span></a></span></span><span> </span><span id="local-6989586621681046352"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046352"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681046351"><span class="annot"><span class="annottext">CmmGraph
</span><a href="#local-6989586621681046351"><span class="hs-identifier hs-var">graph</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; [CmmBlock] -&gt; CmmGraph
</span><a href="GHC.Cmm.Utils.html#ofBlockList"><span class="hs-identifier hs-var">ofBlockList</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmGraph -&gt; BlockId
forall (n :: Extensibility -&gt; Extensibility -&gt; *).
GenCmmGraph n -&gt; BlockId
</span><a href="GHC.Cmm.html#g_entry"><span class="hs-identifier hs-var hs-var">g_entry</span></a></span><span> </span><span class="annot"><span class="annottext">CmmGraph
</span><a href="#local-6989586621681046351"><span class="hs-identifier hs-var">graph</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">([CmmBlock] -&gt; CmmGraph) -&gt; [CmmBlock] -&gt; CmmGraph
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap Assignments -&gt; [CmmBlock] -&gt; [CmmBlock]
</span><a href="#local-6989586621681046348"><span class="hs-identifier hs-var">sink</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap Assignments
forall (map :: * -&gt; *) a. IsMap map =&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapEmpty"><span class="hs-identifier hs-var">mapEmpty</span></a></span><span> </span><span class="annot"><span class="annottext">([CmmBlock] -&gt; [CmmBlock]) -&gt; [CmmBlock] -&gt; [CmmBlock]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[CmmBlock]
</span><a href="#local-6989586621681046346"><span class="hs-identifier hs-var">blocks</span></a></span><span>
</span><span id="line-170"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-171"></span><span>  </span><span id="local-6989586621681046345"><span class="annot"><span class="annottext">liveness :: BlockEntryLiveness LocalReg
</span><a href="#local-6989586621681046345"><span class="hs-identifier hs-var hs-var">liveness</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; CmmGraph -&gt; BlockEntryLiveness LocalReg
</span><a href="GHC.Cmm.Liveness.html#cmmLocalLiveness"><span class="hs-identifier hs-var">cmmLocalLiveness</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046352"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">CmmGraph
</span><a href="#local-6989586621681046351"><span class="hs-identifier hs-var">graph</span></a></span><span>
</span><span id="line-172"></span><span>  </span><span id="local-6989586621681046343"><span class="annot"><span class="annottext">getLive :: BlockId -&gt; Set LocalReg
</span><a href="#local-6989586621681046343"><span class="hs-identifier hs-var hs-var">getLive</span></a></span></span><span> </span><span id="local-6989586621681046342"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681046342"><span class="hs-identifier hs-var">l</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Set LocalReg
-&gt; KeyOf LabelMap -&gt; BlockEntryLiveness LocalReg -&gt; Set LocalReg
forall (map :: * -&gt; *) a. IsMap map =&gt; a -&gt; KeyOf map -&gt; map a -&gt; a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapFindWithDefault"><span class="hs-identifier hs-var">mapFindWithDefault</span></a></span><span> </span><span class="annot"><span class="annottext">Set LocalReg
forall a. Set a
</span><a href="../../containers/src/Data.Set.Internal.html#empty"><span class="hs-identifier hs-var">Set.empty</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
BlockId
</span><a href="#local-6989586621681046342"><span class="hs-identifier hs-var">l</span></a></span><span> </span><span class="annot"><span class="annottext">BlockEntryLiveness LocalReg
</span><a href="#local-6989586621681046345"><span class="hs-identifier hs-var">liveness</span></a></span><span>
</span><span id="line-173"></span><span>
</span><span id="line-174"></span><span>  </span><span id="local-6989586621681046346"><span class="annot"><span class="annottext">blocks :: [CmmBlock]
</span><a href="#local-6989586621681046346"><span class="hs-identifier hs-var hs-var">blocks</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CmmGraph -&gt; [CmmBlock]
</span><a href="GHC.Cmm.Utils.html#revPostorder"><span class="hs-identifier hs-var">revPostorder</span></a></span><span> </span><span class="annot"><span class="annottext">CmmGraph
</span><a href="#local-6989586621681046351"><span class="hs-identifier hs-var">graph</span></a></span><span>
</span><span id="line-175"></span><span>
</span><span id="line-176"></span><span>  </span><span id="local-6989586621681046338"><span class="annot"><span class="annottext">join_pts :: LabelMap Int
</span><a href="#local-6989586621681046338"><span class="hs-identifier hs-var hs-var">join_pts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[CmmBlock] -&gt; LabelMap Int
</span><a href="GHC.Cmm.Sink.html#findJoinPoints"><span class="hs-identifier hs-var">findJoinPoints</span></a></span><span> </span><span class="annot"><span class="annottext">[CmmBlock]
</span><a href="#local-6989586621681046346"><span class="hs-identifier hs-var">blocks</span></a></span><span>
</span><span id="line-177"></span><span>
</span><span id="line-178"></span><span>  </span><span class="annot"><a href="#local-6989586621681046348"><span class="hs-identifier hs-type">sink</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Sink.html#Assignments"><span class="hs-identifier hs-type">Assignments</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.html#CmmBlock"><span class="hs-identifier hs-type">CmmBlock</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.html#CmmBlock"><span class="hs-identifier hs-type">CmmBlock</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-179"></span><span>  </span><span id="local-6989586621681046348"><span class="annot"><span class="annottext">sink :: LabelMap Assignments -&gt; [CmmBlock] -&gt; [CmmBlock]
</span><a href="#local-6989586621681046348"><span class="hs-identifier hs-var hs-var">sink</span></a></span></span><span> </span><span class="annot"><span class="annottext">LabelMap Assignments
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-180"></span><span>  </span><span class="annot"><a href="#local-6989586621681046348"><span class="hs-identifier hs-var">sink</span></a></span><span> </span><span id="local-6989586621681046336"><span class="annot"><span class="annottext">LabelMap Assignments
</span><a href="#local-6989586621681046336"><span class="hs-identifier hs-var">sunk</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681046335"><span class="annot"><span class="annottext">CmmBlock
</span><a href="#local-6989586621681046335"><span class="hs-identifier hs-var">b</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621681046334"><span class="annot"><span class="annottext">[CmmBlock]
</span><a href="#local-6989586621681046334"><span class="hs-identifier hs-var">bs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-181"></span><span>    </span><span class="hs-comment">-- pprTrace &quot;sink&quot; (ppr lbl) $</span><span>
</span><span id="line-182"></span><span>    </span><span class="annot"><span class="annottext">CmmNode C O -&gt; Block CmmNode O O -&gt; CmmNode O C -&gt; CmmBlock
forall (n :: Extensibility -&gt; Extensibility -&gt; *).
n C O -&gt; Block n O O -&gt; n O C -&gt; Block n C C
</span><a href="GHC.Cmm.Dataflow.Block.html#blockJoin"><span class="hs-identifier hs-var">blockJoin</span></a></span><span> </span><span class="annot"><span class="annottext">CmmNode C O
</span><a href="#local-6989586621681046332"><span class="hs-identifier hs-var">first</span></a></span><span> </span><span class="annot"><span class="annottext">Block CmmNode O O
</span><a href="#local-6989586621681046331"><span class="hs-identifier hs-var">final_middle</span></a></span><span> </span><span class="annot"><span class="annottext">CmmNode O C
</span><a href="#local-6989586621681046330"><span class="hs-identifier hs-var">final_last</span></a></span><span> </span><span class="annot"><span class="annottext">CmmBlock -&gt; [CmmBlock] -&gt; [CmmBlock]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">LabelMap Assignments -&gt; [CmmBlock] -&gt; [CmmBlock]
</span><a href="#local-6989586621681046348"><span class="hs-identifier hs-var">sink</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap Assignments
</span><a href="#local-6989586621681046329"><span class="hs-identifier hs-var">sunk'</span></a></span><span> </span><span class="annot"><span class="annottext">[CmmBlock]
</span><a href="#local-6989586621681046334"><span class="hs-identifier hs-var">bs</span></a></span><span>
</span><span id="line-183"></span><span>    </span><span class="hs-keyword">where</span><span>
</span><span id="line-184"></span><span>      </span><span id="local-6989586621681046328"><span class="annot"><span class="annottext">platform :: Platform
</span><a href="#local-6989586621681046328"><span class="hs-identifier hs-var hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Platform
</span><a href="GHC.Driver.Session.html#targetPlatform"><span class="hs-identifier hs-var hs-var">targetPlatform</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046352"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-185"></span><span>      </span><span id="local-6989586621681046326"><span class="annot"><span class="annottext">lbl :: BlockId
</span><a href="#local-6989586621681046326"><span class="hs-identifier hs-var hs-var">lbl</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CmmBlock -&gt; BlockId
forall (thing :: Extensibility -&gt; Extensibility -&gt; *)
       (x :: Extensibility).
NonLocal thing =&gt;
thing C x -&gt; BlockId
</span><a href="GHC.Cmm.Dataflow.Graph.html#entryLabel"><span class="hs-identifier hs-var">entryLabel</span></a></span><span> </span><span class="annot"><span class="annottext">CmmBlock
</span><a href="#local-6989586621681046335"><span class="hs-identifier hs-var">b</span></a></span><span>
</span><span id="line-186"></span><span>      </span><span class="hs-special">(</span><span id="local-6989586621681046332"><span class="annot"><span class="annottext">CmmNode C O
</span><a href="#local-6989586621681046332"><span class="hs-identifier hs-var">first</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681046324"><span class="annot"><span class="annottext">Block CmmNode O O
</span><a href="#local-6989586621681046324"><span class="hs-identifier hs-var">middle</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681046323"><span class="annot"><span class="annottext">CmmNode O C
</span><a href="#local-6989586621681046323"><span class="hs-identifier hs-var">last</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CmmBlock -&gt; (CmmNode C O, Block CmmNode O O, CmmNode O C)
forall (n :: Extensibility -&gt; Extensibility -&gt; *).
Block n C C -&gt; (n C O, Block n O O, n O C)
</span><a href="GHC.Cmm.Dataflow.Block.html#blockSplit"><span class="hs-identifier hs-var">blockSplit</span></a></span><span> </span><span class="annot"><span class="annottext">CmmBlock
</span><a href="#local-6989586621681046335"><span class="hs-identifier hs-var">b</span></a></span><span>
</span><span id="line-187"></span><span>
</span><span id="line-188"></span><span>      </span><span id="local-6989586621681046321"><span class="annot"><span class="annottext">succs :: [BlockId]
</span><a href="#local-6989586621681046321"><span class="hs-identifier hs-var hs-var">succs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CmmNode O C -&gt; [BlockId]
forall (thing :: Extensibility -&gt; Extensibility -&gt; *)
       (e :: Extensibility).
NonLocal thing =&gt;
thing e C -&gt; [BlockId]
</span><a href="GHC.Cmm.Dataflow.Graph.html#successors"><span class="hs-identifier hs-var">successors</span></a></span><span> </span><span class="annot"><span class="annottext">CmmNode O C
</span><a href="#local-6989586621681046323"><span class="hs-identifier hs-var">last</span></a></span><span>
</span><span id="line-189"></span><span>
</span><span id="line-190"></span><span>      </span><span class="hs-comment">-- Annotate the middle nodes with the registers live *after*</span><span>
</span><span id="line-191"></span><span>      </span><span class="hs-comment">-- the node.  This will help us decide whether we can inline</span><span>
</span><span id="line-192"></span><span>      </span><span class="hs-comment">-- an assignment in the current node or not.</span><span>
</span><span id="line-193"></span><span>      </span><span id="local-6989586621681046319"><span class="annot"><span class="annottext">live :: Set LocalReg
</span><a href="#local-6989586621681046319"><span class="hs-identifier hs-var hs-var">live</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Set LocalReg] -&gt; Set LocalReg
forall (f :: * -&gt; *) a. (Foldable f, Ord a) =&gt; f (Set a) -&gt; Set a
</span><a href="../../containers/src/Data.Set.Internal.html#unions"><span class="hs-identifier hs-var">Set.unions</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(BlockId -&gt; Set LocalReg) -&gt; [BlockId] -&gt; [Set LocalReg]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; Set LocalReg
</span><a href="#local-6989586621681046343"><span class="hs-identifier hs-var">getLive</span></a></span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681046321"><span class="hs-identifier hs-var">succs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-194"></span><span>      </span><span id="local-6989586621681046317"><span class="annot"><span class="annottext">live_middle :: Set LocalReg
</span><a href="#local-6989586621681046317"><span class="hs-identifier hs-var hs-var">live_middle</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; CmmNode O C -&gt; Set LocalReg -&gt; Set LocalReg
forall r n.
(DefinerOfRegs r n, UserOfRegs r n) =&gt;
DynFlags -&gt; n -&gt; CmmLive r -&gt; CmmLive r
</span><a href="GHC.Cmm.Liveness.html#gen_kill"><span class="hs-identifier hs-var">gen_kill</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046352"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">CmmNode O C
</span><a href="#local-6989586621681046323"><span class="hs-identifier hs-var">last</span></a></span><span> </span><span class="annot"><span class="annottext">Set LocalReg
</span><a href="#local-6989586621681046319"><span class="hs-identifier hs-var">live</span></a></span><span>
</span><span id="line-195"></span><span>      </span><span id="local-6989586621681046315"><span class="annot"><span class="annottext">ann_middles :: [(Set LocalReg, CmmNode O O)]
</span><a href="#local-6989586621681046315"><span class="hs-identifier hs-var hs-var">ann_middles</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags
-&gt; Set LocalReg -&gt; [CmmNode O O] -&gt; [(Set LocalReg, CmmNode O O)]
</span><a href="GHC.Cmm.Sink.html#annotate"><span class="hs-identifier hs-var">annotate</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046352"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Set LocalReg
</span><a href="#local-6989586621681046317"><span class="hs-identifier hs-var">live_middle</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Block CmmNode O O -&gt; [CmmNode O O]
forall (n :: Extensibility -&gt; Extensibility -&gt; *).
Block n O O -&gt; [n O O]
</span><a href="GHC.Cmm.Dataflow.Block.html#blockToList"><span class="hs-identifier hs-var">blockToList</span></a></span><span> </span><span class="annot"><span class="annottext">Block CmmNode O O
</span><a href="#local-6989586621681046324"><span class="hs-identifier hs-var">middle</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-196"></span><span>
</span><span id="line-197"></span><span>      </span><span class="hs-comment">-- Now sink and inline in this block</span><span>
</span><span id="line-198"></span><span>      </span><span class="hs-special">(</span><span id="local-6989586621681046312"><span class="annot"><span class="annottext">Block CmmNode O O
</span><a href="#local-6989586621681046312"><span class="hs-identifier hs-var">middle'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681046311"><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046311"><span class="hs-identifier hs-var">assigs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags
-&gt; [(Set LocalReg, CmmNode O O)]
-&gt; Assignments
-&gt; (Block CmmNode O O, Assignments)
</span><a href="GHC.Cmm.Sink.html#walk"><span class="hs-identifier hs-var">walk</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046352"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">[(Set LocalReg, CmmNode O O)]
</span><a href="#local-6989586621681046315"><span class="hs-identifier hs-var">ann_middles</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Assignments
-&gt; KeyOf LabelMap -&gt; LabelMap Assignments -&gt; Assignments
forall (map :: * -&gt; *) a. IsMap map =&gt; a -&gt; KeyOf map -&gt; map a -&gt; a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapFindWithDefault"><span class="hs-identifier hs-var">mapFindWithDefault</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
BlockId
</span><a href="#local-6989586621681046326"><span class="hs-identifier hs-var">lbl</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap Assignments
</span><a href="#local-6989586621681046336"><span class="hs-identifier hs-var">sunk</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-199"></span><span>      </span><span id="local-6989586621681046309"><span class="annot"><span class="annottext">fold_last :: CmmNode O C
</span><a href="#local-6989586621681046309"><span class="hs-identifier hs-var hs-var">fold_last</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; CmmNode O C -&gt; CmmNode O C
forall (e :: Extensibility) (x :: Extensibility).
Platform -&gt; CmmNode e x -&gt; CmmNode e x
</span><a href="GHC.Cmm.Opt.html#constantFoldNode"><span class="hs-identifier hs-var">constantFoldNode</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681046328"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">CmmNode O C
</span><a href="#local-6989586621681046323"><span class="hs-identifier hs-var">last</span></a></span><span>
</span><span id="line-200"></span><span>      </span><span class="hs-special">(</span><span id="local-6989586621681046330"><span class="annot"><span class="annottext">CmmNode O C
</span><a href="#local-6989586621681046330"><span class="hs-identifier hs-var">final_last</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681046307"><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046307"><span class="hs-identifier hs-var">assigs'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags
-&gt; Set LocalReg
-&gt; CmmNode O C
-&gt; Assignments
-&gt; (CmmNode O C, Assignments)
forall (x :: Extensibility).
DynFlags
-&gt; Set LocalReg
-&gt; CmmNode O x
-&gt; Assignments
-&gt; (CmmNode O x, Assignments)
</span><a href="GHC.Cmm.Sink.html#tryToInline"><span class="hs-identifier hs-var">tryToInline</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046352"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Set LocalReg
</span><a href="#local-6989586621681046319"><span class="hs-identifier hs-var">live</span></a></span><span> </span><span class="annot"><span class="annottext">CmmNode O C
</span><a href="#local-6989586621681046309"><span class="hs-identifier hs-var">fold_last</span></a></span><span> </span><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046311"><span class="hs-identifier hs-var">assigs</span></a></span><span>
</span><span id="line-201"></span><span>
</span><span id="line-202"></span><span>      </span><span class="hs-comment">-- We cannot sink into join points (successors with more than</span><span>
</span><span id="line-203"></span><span>      </span><span class="hs-comment">-- one predecessor), so identify the join points and the set</span><span>
</span><span id="line-204"></span><span>      </span><span class="hs-comment">-- of registers live in them.</span><span>
</span><span id="line-205"></span><span>      </span><span class="hs-special">(</span><span id="local-6989586621681046305"><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681046305"><span class="hs-identifier hs-var">joins</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681046304"><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681046304"><span class="hs-identifier hs-var">nonjoins</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(BlockId -&gt; Bool) -&gt; [BlockId] -&gt; ([BlockId], [BlockId])
forall a. (a -&gt; Bool) -&gt; [a] -&gt; ([a], [a])
</span><a href="../../base/src/Data.OldList.html#partition"><span class="hs-identifier hs-var">partition</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">KeyOf LabelMap -&gt; LabelMap Int -&gt; Bool
forall (map :: * -&gt; *) a. IsMap map =&gt; KeyOf map -&gt; map a -&gt; Bool
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapMember"><span class="hs-operator hs-var">`mapMember`</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap Int
</span><a href="#local-6989586621681046338"><span class="hs-identifier hs-var">join_pts</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681046321"><span class="hs-identifier hs-var">succs</span></a></span><span>
</span><span id="line-206"></span><span>      </span><span id="local-6989586621681046302"><span class="annot"><span class="annottext">live_in_joins :: Set LocalReg
</span><a href="#local-6989586621681046302"><span class="hs-identifier hs-var hs-var">live_in_joins</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Set LocalReg] -&gt; Set LocalReg
forall (f :: * -&gt; *) a. (Foldable f, Ord a) =&gt; f (Set a) -&gt; Set a
</span><a href="../../containers/src/Data.Set.Internal.html#unions"><span class="hs-identifier hs-var">Set.unions</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(BlockId -&gt; Set LocalReg) -&gt; [BlockId] -&gt; [Set LocalReg]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; Set LocalReg
</span><a href="#local-6989586621681046343"><span class="hs-identifier hs-var">getLive</span></a></span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681046305"><span class="hs-identifier hs-var">joins</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-207"></span><span>
</span><span id="line-208"></span><span>      </span><span class="hs-comment">-- We do not want to sink an assignment into multiple branches,</span><span>
</span><span id="line-209"></span><span>      </span><span class="hs-comment">-- so identify the set of registers live in multiple successors.</span><span>
</span><span id="line-210"></span><span>      </span><span class="hs-comment">-- This is made more complicated because when we sink an assignment</span><span>
</span><span id="line-211"></span><span>      </span><span class="hs-comment">-- into one branch, this might change the set of registers that are</span><span>
</span><span id="line-212"></span><span>      </span><span class="hs-comment">-- now live in multiple branches.</span><span>
</span><span id="line-213"></span><span>      </span><span id="local-6989586621681046301"><span class="annot"><span class="annottext">init_live_sets :: [Set LocalReg]
</span><a href="#local-6989586621681046301"><span class="hs-identifier hs-var hs-var">init_live_sets</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(BlockId -&gt; Set LocalReg) -&gt; [BlockId] -&gt; [Set LocalReg]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; Set LocalReg
</span><a href="#local-6989586621681046343"><span class="hs-identifier hs-var">getLive</span></a></span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681046304"><span class="hs-identifier hs-var">nonjoins</span></a></span><span>
</span><span id="line-214"></span><span>      </span><span id="local-6989586621681046298"><span class="annot"><span class="annottext">live_in_multi :: [Set a] -&gt; a -&gt; Bool
</span><a href="#local-6989586621681046298"><span class="hs-identifier hs-var hs-var">live_in_multi</span></a></span></span><span> </span><span id="local-6989586621681046297"><span class="annot"><span class="annottext">[Set a]
</span><a href="#local-6989586621681046297"><span class="hs-identifier hs-var">live_sets</span></a></span></span><span> </span><span id="local-6989586621681046296"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681046296"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-215"></span><span>         </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">(Set a -&gt; Bool) -&gt; [Set a] -&gt; [Set a]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; Set a -&gt; Bool
forall a. Ord a =&gt; a -&gt; Set a -&gt; Bool
</span><a href="../../containers/src/Data.Set.Internal.html#member"><span class="hs-identifier hs-var">Set.member</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681046296"><span class="hs-identifier hs-var">r</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Set a]
</span><a href="#local-6989586621681046297"><span class="hs-identifier hs-var">live_sets</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-216"></span><span>           </span><span class="hs-special">(</span><span id="local-6989586621681046294"><span class="annot"><span class="annottext">Set a
</span><a href="#local-6989586621681046294"><span class="hs-identifier hs-var">_one</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621681046293"><span class="annot"><span class="annottext">Set a
</span><a href="#local-6989586621681046293"><span class="hs-identifier hs-var">_two</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span class="annot"><span class="annottext">[Set a]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-217"></span><span>           </span><span class="annot"><span class="annottext">[Set a]
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-218"></span><span>
</span><span id="line-219"></span><span>      </span><span class="hs-comment">-- Now, drop any assignments that we will not sink any further.</span><span>
</span><span id="line-220"></span><span>      </span><span class="hs-special">(</span><span id="local-6989586621681046292"><span class="annot"><span class="annottext">[CmmNode O O]
</span><a href="#local-6989586621681046292"><span class="hs-identifier hs-var">dropped_last</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681046291"><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046291"><span class="hs-identifier hs-var">assigs''</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags
-&gt; (Assignment -&gt; [Set LocalReg] -&gt; (Bool, [Set LocalReg]))
-&gt; [Set LocalReg]
-&gt; Assignments
-&gt; ([CmmNode O O], Assignments)
forall s.
DynFlags
-&gt; (Assignment -&gt; s -&gt; (Bool, s))
-&gt; s
-&gt; Assignments
-&gt; ([CmmNode O O], Assignments)
</span><a href="GHC.Cmm.Sink.html#dropAssignments"><span class="hs-identifier hs-var">dropAssignments</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046352"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Assignment -&gt; [Set LocalReg] -&gt; (Bool, [Set LocalReg])
</span><a href="#local-6989586621681046289"><span class="hs-identifier hs-var">drop_if</span></a></span><span> </span><span class="annot"><span class="annottext">[Set LocalReg]
</span><a href="#local-6989586621681046301"><span class="hs-identifier hs-var">init_live_sets</span></a></span><span> </span><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046307"><span class="hs-identifier hs-var">assigs'</span></a></span><span>
</span><span id="line-221"></span><span>
</span><span id="line-222"></span><span>      </span><span id="local-6989586621681046289"><span class="annot"><span class="annottext">drop_if :: Assignment -&gt; [Set LocalReg] -&gt; (Bool, [Set LocalReg])
</span><a href="#local-6989586621681046289"><span class="hs-identifier hs-var hs-var">drop_if</span></a></span></span><span> </span><span id="local-6989586621681046288"><span class="annot"><span class="annottext">a :: Assignment
</span><a href="#local-6989586621681046288"><span class="hs-identifier hs-var">a</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span id="local-6989586621681046287"><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681046287"><span class="hs-identifier hs-var">r</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681046286"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681046286"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">AbsMem
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681046285"><span class="annot"><span class="annottext">[Set LocalReg]
</span><a href="#local-6989586621681046285"><span class="hs-identifier hs-var">live_sets</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681046284"><span class="hs-identifier hs-var">should_drop</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Set LocalReg]
</span><a href="#local-6989586621681046283"><span class="hs-identifier hs-var">live_sets'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-223"></span><span>          </span><span class="hs-keyword">where</span><span>
</span><span id="line-224"></span><span>            </span><span id="local-6989586621681046284"><span class="annot"><span class="annottext">should_drop :: Bool
</span><a href="#local-6989586621681046284"><span class="hs-identifier hs-var hs-var">should_drop</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>  </span><span class="annot"><span class="annottext">DynFlags -&gt; Assignment -&gt; CmmNode O C -&gt; Bool
forall (x :: Extensibility).
DynFlags -&gt; Assignment -&gt; CmmNode O x -&gt; Bool
</span><a href="GHC.Cmm.Sink.html#conflicts"><span class="hs-identifier hs-var">conflicts</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046352"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Assignment
</span><a href="#local-6989586621681046288"><span class="hs-identifier hs-var">a</span></a></span><span> </span><span class="annot"><span class="annottext">CmmNode O C
</span><a href="#local-6989586621681046330"><span class="hs-identifier hs-var">final_last</span></a></span><span>
</span><span id="line-225"></span><span>                        </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; CmmExpr -&gt; Bool
</span><a href="GHC.Cmm.Sink.html#isTrivial"><span class="hs-identifier hs-var">isTrivial</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046352"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681046286"><span class="hs-identifier hs-var">rhs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">[Set LocalReg] -&gt; LocalReg -&gt; Bool
forall {a}. Ord a =&gt; [Set a] -&gt; a -&gt; Bool
</span><a href="#local-6989586621681046298"><span class="hs-identifier hs-var">live_in_multi</span></a></span><span> </span><span class="annot"><span class="annottext">[Set LocalReg]
</span><a href="#local-6989586621681046285"><span class="hs-identifier hs-var">live_sets</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681046287"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-226"></span><span>                        </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681046287"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg -&gt; Set LocalReg -&gt; Bool
forall a. Ord a =&gt; a -&gt; Set a -&gt; Bool
</span><a href="../../containers/src/Data.Set.Internal.html#member"><span class="hs-operator hs-var">`Set.member`</span></a></span><span> </span><span class="annot"><span class="annottext">Set LocalReg
</span><a href="#local-6989586621681046302"><span class="hs-identifier hs-var">live_in_joins</span></a></span><span>
</span><span id="line-227"></span><span>
</span><span id="line-228"></span><span>            </span><span id="local-6989586621681046283"><span class="annot"><span class="annottext">live_sets' :: [Set LocalReg]
</span><a href="#local-6989586621681046283"><span class="hs-identifier hs-var hs-var">live_sets'</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681046284"><span class="hs-identifier hs-var">should_drop</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Set LocalReg]
</span><a href="#local-6989586621681046285"><span class="hs-identifier hs-var">live_sets</span></a></span><span>
</span><span id="line-229"></span><span>                       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Set LocalReg -&gt; Set LocalReg) -&gt; [Set LocalReg] -&gt; [Set LocalReg]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Set LocalReg -&gt; Set LocalReg
</span><a href="#local-6989586621681046277"><span class="hs-identifier hs-var">upd</span></a></span><span> </span><span class="annot"><span class="annottext">[Set LocalReg]
</span><a href="#local-6989586621681046285"><span class="hs-identifier hs-var">live_sets</span></a></span><span>
</span><span id="line-230"></span><span>
</span><span id="line-231"></span><span>            </span><span id="local-6989586621681046277"><span class="annot"><span class="annottext">upd :: Set LocalReg -&gt; Set LocalReg
</span><a href="#local-6989586621681046277"><span class="hs-identifier hs-var hs-var">upd</span></a></span></span><span> </span><span id="local-6989586621681046276"><span class="annot"><span class="annottext">Set LocalReg
</span><a href="#local-6989586621681046276"><span class="hs-identifier hs-var">set</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681046287"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg -&gt; Set LocalReg -&gt; Bool
forall a. Ord a =&gt; a -&gt; Set a -&gt; Bool
</span><a href="../../containers/src/Data.Set.Internal.html#member"><span class="hs-operator hs-var">`Set.member`</span></a></span><span> </span><span class="annot"><span class="annottext">Set LocalReg
</span><a href="#local-6989586621681046276"><span class="hs-identifier hs-var">set</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Set LocalReg
</span><a href="#local-6989586621681046276"><span class="hs-identifier hs-var">set</span></a></span><span> </span><span class="annot"><span class="annottext">Set LocalReg -&gt; Set LocalReg -&gt; Set LocalReg
forall a. Ord a =&gt; Set a -&gt; Set a -&gt; Set a
</span><a href="../../containers/src/Data.Set.Internal.html#union"><span class="hs-operator hs-var">`Set.union`</span></a></span><span> </span><span class="annot"><span class="annottext">Set LocalReg
</span><a href="#local-6989586621681046274"><span class="hs-identifier hs-var">live_rhs</span></a></span><span>
</span><span id="line-232"></span><span>                    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Set LocalReg
</span><a href="#local-6989586621681046276"><span class="hs-identifier hs-var">set</span></a></span><span>
</span><span id="line-233"></span><span>
</span><span id="line-234"></span><span>            </span><span id="local-6989586621681046274"><span class="annot"><span class="annottext">live_rhs :: Set LocalReg
</span><a href="#local-6989586621681046274"><span class="hs-identifier hs-var hs-var">live_rhs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags
-&gt; (Set LocalReg -&gt; LocalReg -&gt; Set LocalReg)
-&gt; Set LocalReg
-&gt; CmmExpr
-&gt; Set LocalReg
forall r a b.
UserOfRegs r a =&gt;
DynFlags -&gt; (b -&gt; r -&gt; b) -&gt; b -&gt; a -&gt; b
</span><a href="GHC.Cmm.Expr.html#foldRegsUsed"><span class="hs-identifier hs-var">foldRegsUsed</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046352"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Set LocalReg -&gt; LocalReg -&gt; Set LocalReg
forall r. Ord r =&gt; RegSet r -&gt; r -&gt; RegSet r
</span><a href="GHC.Cmm.Expr.html#extendRegSet"><span class="hs-identifier hs-var">extendRegSet</span></a></span><span> </span><span class="annot"><span class="annottext">Set LocalReg
forall a. Set a
</span><a href="GHC.Cmm.Expr.html#emptyRegSet"><span class="hs-identifier hs-var">emptyRegSet</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681046286"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-235"></span><span>
</span><span id="line-236"></span><span>      </span><span id="local-6989586621681046331"><span class="annot"><span class="annottext">final_middle :: Block CmmNode O O
</span><a href="#local-6989586621681046331"><span class="hs-identifier hs-var hs-var">final_middle</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Block CmmNode O O -&gt; CmmNode O O -&gt; Block CmmNode O O)
-&gt; Block CmmNode O O -&gt; [CmmNode O O] -&gt; Block CmmNode O O
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="annot"><span class="annottext">Block CmmNode O O -&gt; CmmNode O O -&gt; Block CmmNode O O
forall (n :: Extensibility -&gt; Extensibility -&gt; *)
       (e :: Extensibility).
Block n e O -&gt; n O O -&gt; Block n e O
</span><a href="GHC.Cmm.Dataflow.Block.html#blockSnoc"><span class="hs-identifier hs-var">blockSnoc</span></a></span><span> </span><span class="annot"><span class="annottext">Block CmmNode O O
</span><a href="#local-6989586621681046312"><span class="hs-identifier hs-var">middle'</span></a></span><span> </span><span class="annot"><span class="annottext">[CmmNode O O]
</span><a href="#local-6989586621681046292"><span class="hs-identifier hs-var">dropped_last</span></a></span><span>
</span><span id="line-237"></span><span>
</span><span id="line-238"></span><span>      </span><span id="local-6989586621681046329"><span class="annot"><span class="annottext">sunk' :: LabelMap Assignments
</span><a href="#local-6989586621681046329"><span class="hs-identifier hs-var hs-var">sunk'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LabelMap Assignments
-&gt; LabelMap Assignments -&gt; LabelMap Assignments
forall (map :: * -&gt; *) a. IsMap map =&gt; map a -&gt; map a -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapUnion"><span class="hs-identifier hs-var">mapUnion</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap Assignments
</span><a href="#local-6989586621681046336"><span class="hs-identifier hs-var">sunk</span></a></span><span> </span><span class="annot"><span class="annottext">(LabelMap Assignments -&gt; LabelMap Assignments)
-&gt; LabelMap Assignments -&gt; LabelMap Assignments
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-239"></span><span>                 </span><span class="annot"><span class="annottext">[(KeyOf LabelMap, Assignments)] -&gt; LabelMap Assignments
forall (map :: * -&gt; *) a. IsMap map =&gt; [(KeyOf map, a)] -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapFromList"><span class="hs-identifier hs-var">mapFromList</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">KeyOf LabelMap
BlockId
</span><a href="#local-6989586621681046266"><span class="hs-identifier hs-var">l</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Set LocalReg -&gt; Assignments -&gt; Assignments
</span><a href="GHC.Cmm.Sink.html#filterAssignments"><span class="hs-identifier hs-var">filterAssignments</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046352"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockId -&gt; Set LocalReg
</span><a href="#local-6989586621681046343"><span class="hs-identifier hs-var">getLive</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681046266"><span class="hs-identifier hs-var">l</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046291"><span class="hs-identifier hs-var">assigs''</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-240"></span><span>                             </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621681046266"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681046266"><span class="hs-identifier hs-var">l</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681046321"><span class="hs-identifier hs-var">succs</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-241"></span><span>
</span><span id="line-242"></span><span class="hs-comment">{- TODO: enable this later, when we have some good tests in place to
   measure the effect and tune it.

-- small: an expression we don't mind duplicating
isSmall :: CmmExpr -&gt; Bool
isSmall (CmmReg (CmmLocal _)) = True  --
isSmall (CmmLit _) = True
isSmall (CmmMachOp (MO_Add _) [x,y]) = isTrivial x &amp;&amp; isTrivial y
isSmall (CmmRegOff (CmmLocal _) _) = True
isSmall _ = False
-}</span><span>
</span><span id="line-253"></span><span>
</span><span id="line-254"></span><span class="hs-comment">--</span><span>
</span><span id="line-255"></span><span class="hs-comment">-- We allow duplication of trivial expressions: registers (both local and</span><span>
</span><span id="line-256"></span><span class="hs-comment">-- global) and literals.</span><span>
</span><span id="line-257"></span><span class="hs-comment">--</span><span>
</span><span id="line-258"></span><span class="annot"><a href="GHC.Cmm.Sink.html#isTrivial"><span class="hs-identifier hs-type">isTrivial</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-259"></span><span id="isTrivial"><span class="annot"><span class="annottext">isTrivial :: DynFlags -&gt; CmmExpr -&gt; Bool
</span><a href="GHC.Cmm.Sink.html#isTrivial"><span class="hs-identifier hs-var hs-var">isTrivial</span></a></span></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmReg"><span class="hs-identifier hs-type">CmmReg</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmLocal"><span class="hs-identifier hs-type">CmmLocal</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-260"></span><span class="annot"><a href="GHC.Cmm.Sink.html#isTrivial"><span class="hs-identifier hs-var">isTrivial</span></a></span><span> </span><span id="local-6989586621681046262"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046262"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmReg"><span class="hs-identifier hs-type">CmmReg</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmGlobal"><span class="hs-identifier hs-type">CmmGlobal</span></a></span><span> </span><span id="local-6989586621681046260"><span class="annot"><span class="annottext">GlobalReg
</span><a href="#local-6989586621681046260"><span class="hs-identifier hs-var">r</span></a></span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- see Note [Inline GlobalRegs?]</span><span>
</span><span id="line-261"></span><span>  </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Arch -&gt; Bool
</span><a href="../../ghc-boot/src/GHC.Platform.html#isARM"><span class="hs-identifier hs-var">isARM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; Arch
</span><a href="../../ghc-boot/src/GHC.Platform.html#platformArch"><span class="hs-identifier hs-var">platformArch</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; Platform
</span><a href="GHC.Driver.Session.html#targetPlatform"><span class="hs-identifier hs-var hs-var">targetPlatform</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046262"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-262"></span><span>  </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="hs-comment">-- CodeGen.Platform.ARM does not have globalRegMaybe</span><span>
</span><span id="line-263"></span><span>  </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Maybe RealReg -&gt; Bool
forall a. Maybe a -&gt; Bool
</span><a href="../../base/src/Data.Maybe.html#isJust"><span class="hs-identifier hs-var">isJust</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; GlobalReg -&gt; Maybe RealReg
</span><a href="GHC.Platform.Regs.html#globalRegMaybe"><span class="hs-identifier hs-var">globalRegMaybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; Platform
</span><a href="GHC.Driver.Session.html#targetPlatform"><span class="hs-identifier hs-var hs-var">targetPlatform</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046262"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">GlobalReg
</span><a href="#local-6989586621681046260"><span class="hs-identifier hs-var">r</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-264"></span><span>  </span><span class="hs-comment">-- GlobalRegs that are loads from BaseReg are not trivial</span><span>
</span><span id="line-265"></span><span class="annot"><a href="GHC.Cmm.Sink.html#isTrivial"><span class="hs-identifier hs-var">isTrivial</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmLit"><span class="hs-identifier hs-type">CmmLit</span></a></span><span> </span><span class="annot"><span class="annottext">CmmLit
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-266"></span><span class="annot"><a href="GHC.Cmm.Sink.html#isTrivial"><span class="hs-identifier hs-var">isTrivial</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><span class="hs-identifier">_</span></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-267"></span><span>
</span><span id="line-268"></span><span class="hs-comment">--</span><span>
</span><span id="line-269"></span><span class="hs-comment">-- annotate each node with the set of registers live *after* the node</span><span>
</span><span id="line-270"></span><span class="hs-comment">--</span><span>
</span><span id="line-271"></span><span class="annot"><a href="GHC.Cmm.Sink.html#annotate"><span class="hs-identifier hs-type">annotate</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#LocalRegSet"><span class="hs-identifier hs-type">LocalRegSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.Node.html#CmmNode"><span class="hs-identifier hs-type">CmmNode</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Block.html#O"><span class="hs-identifier hs-type">O</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Block.html#O"><span class="hs-identifier hs-type">O</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Expr.html#LocalRegSet"><span class="hs-identifier hs-type">LocalRegSet</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Cmm.Node.html#CmmNode"><span class="hs-identifier hs-type">CmmNode</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Block.html#O"><span class="hs-identifier hs-type">O</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Block.html#O"><span class="hs-identifier hs-type">O</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-272"></span><span id="annotate"><span class="annot"><span class="annottext">annotate :: DynFlags
-&gt; Set LocalReg -&gt; [CmmNode O O] -&gt; [(Set LocalReg, CmmNode O O)]
</span><a href="GHC.Cmm.Sink.html#annotate"><span class="hs-identifier hs-var hs-var">annotate</span></a></span></span><span> </span><span id="local-6989586621681046253"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046253"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681046252"><span class="annot"><span class="annottext">Set LocalReg
</span><a href="#local-6989586621681046252"><span class="hs-identifier hs-var">live</span></a></span></span><span> </span><span id="local-6989586621681046251"><span class="annot"><span class="annottext">[CmmNode O O]
</span><a href="#local-6989586621681046251"><span class="hs-identifier hs-var">nodes</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Set LocalReg, [(Set LocalReg, CmmNode O O)])
-&gt; [(Set LocalReg, CmmNode O O)]
forall a b. (a, b) -&gt; b
</span><a href="../../base/src/Data.Tuple.html#snd"><span class="hs-identifier hs-var">snd</span></a></span><span> </span><span class="annot"><span class="annottext">((Set LocalReg, [(Set LocalReg, CmmNode O O)])
 -&gt; [(Set LocalReg, CmmNode O O)])
-&gt; (Set LocalReg, [(Set LocalReg, CmmNode O O)])
-&gt; [(Set LocalReg, CmmNode O O)]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(CmmNode O O
 -&gt; (Set LocalReg, [(Set LocalReg, CmmNode O O)])
 -&gt; (Set LocalReg, [(Set LocalReg, CmmNode O O)]))
-&gt; (Set LocalReg, [(Set LocalReg, CmmNode O O)])
-&gt; [CmmNode O O]
-&gt; (Set LocalReg, [(Set LocalReg, CmmNode O O)])
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="annot"><span class="annottext">CmmNode O O
-&gt; (Set LocalReg, [(Set LocalReg, CmmNode O O)])
-&gt; (Set LocalReg, [(Set LocalReg, CmmNode O O)])
</span><a href="#local-6989586621681046249"><span class="hs-identifier hs-var">ann</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Set LocalReg
</span><a href="#local-6989586621681046252"><span class="hs-identifier hs-var">live</span></a></span><span class="hs-special">,</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[CmmNode O O]
</span><a href="#local-6989586621681046251"><span class="hs-identifier hs-var">nodes</span></a></span><span>
</span><span id="line-273"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621681046249"><span class="annot"><span class="annottext">ann :: CmmNode O O
-&gt; (Set LocalReg, [(Set LocalReg, CmmNode O O)])
-&gt; (Set LocalReg, [(Set LocalReg, CmmNode O O)])
</span><a href="#local-6989586621681046249"><span class="hs-identifier hs-var hs-var">ann</span></a></span></span><span> </span><span id="local-6989586621681046248"><span class="annot"><span class="annottext">CmmNode O O
</span><a href="#local-6989586621681046248"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681046247"><span class="annot"><span class="annottext">Set LocalReg
</span><a href="#local-6989586621681046247"><span class="hs-identifier hs-var">live</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681046246"><span class="annot"><span class="annottext">[(Set LocalReg, CmmNode O O)]
</span><a href="#local-6989586621681046246"><span class="hs-identifier hs-var">nodes</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; CmmNode O O -&gt; Set LocalReg -&gt; Set LocalReg
forall r n.
(DefinerOfRegs r n, UserOfRegs r n) =&gt;
DynFlags -&gt; n -&gt; CmmLive r -&gt; CmmLive r
</span><a href="GHC.Cmm.Liveness.html#gen_kill"><span class="hs-identifier hs-var">gen_kill</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046253"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">CmmNode O O
</span><a href="#local-6989586621681046248"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Set LocalReg
</span><a href="#local-6989586621681046247"><span class="hs-identifier hs-var">live</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Set LocalReg
</span><a href="#local-6989586621681046247"><span class="hs-identifier hs-var">live</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">CmmNode O O
</span><a href="#local-6989586621681046248"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(Set LocalReg, CmmNode O O)
-&gt; [(Set LocalReg, CmmNode O O)] -&gt; [(Set LocalReg, CmmNode O O)]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[(Set LocalReg, CmmNode O O)]
</span><a href="#local-6989586621681046246"><span class="hs-identifier hs-var">nodes</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-274"></span><span>
</span><span id="line-275"></span><span class="hs-comment">--</span><span>
</span><span id="line-276"></span><span class="hs-comment">-- Find the blocks that have multiple successors (join points)</span><span>
</span><span id="line-277"></span><span class="hs-comment">--</span><span>
</span><span id="line-278"></span><span class="annot"><a href="GHC.Cmm.Sink.html#findJoinPoints"><span class="hs-identifier hs-type">findJoinPoints</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.html#CmmBlock"><span class="hs-identifier hs-type">CmmBlock</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>
</span><span id="line-279"></span><span id="findJoinPoints"><span class="annot"><span class="annottext">findJoinPoints :: [CmmBlock] -&gt; LabelMap Int
</span><a href="GHC.Cmm.Sink.html#findJoinPoints"><span class="hs-identifier hs-var hs-var">findJoinPoints</span></a></span></span><span> </span><span id="local-6989586621681046245"><span class="annot"><span class="annottext">[CmmBlock]
</span><a href="#local-6989586621681046245"><span class="hs-identifier hs-var">blocks</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Int -&gt; Bool) -&gt; LabelMap Int -&gt; LabelMap Int
forall (map :: * -&gt; *) a.
IsMap map =&gt;
(a -&gt; Bool) -&gt; map a -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapFilter"><span class="hs-identifier hs-var">mapFilter</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;</span></span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">LabelMap Int
</span><a href="#local-6989586621681046242"><span class="hs-identifier hs-var">succ_counts</span></a></span><span>
</span><span id="line-280"></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-281"></span><span>  </span><span id="local-6989586621681046241"><span class="annot"><span class="annottext">all_succs :: [BlockId]
</span><a href="#local-6989586621681046241"><span class="hs-identifier hs-var hs-var">all_succs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CmmBlock -&gt; [BlockId]) -&gt; [CmmBlock] -&gt; [BlockId]
forall (t :: * -&gt; *) a b. Foldable t =&gt; (a -&gt; [b]) -&gt; t a -&gt; [b]
</span><a href="../../base/src/Data.Foldable.html#concatMap"><span class="hs-identifier hs-var">concatMap</span></a></span><span> </span><span class="annot"><span class="annottext">CmmBlock -&gt; [BlockId]
forall (thing :: Extensibility -&gt; Extensibility -&gt; *)
       (e :: Extensibility).
NonLocal thing =&gt;
thing e C -&gt; [BlockId]
</span><a href="GHC.Cmm.Dataflow.Graph.html#successors"><span class="hs-identifier hs-var">successors</span></a></span><span> </span><span class="annot"><span class="annottext">[CmmBlock]
</span><a href="#local-6989586621681046245"><span class="hs-identifier hs-var">blocks</span></a></span><span>
</span><span id="line-282"></span><span>
</span><span id="line-283"></span><span>  </span><span class="annot"><a href="#local-6989586621681046242"><span class="hs-identifier hs-type">succ_counts</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>
</span><span id="line-284"></span><span>  </span><span id="local-6989586621681046242"><span class="annot"><span class="annottext">succ_counts :: LabelMap Int
</span><a href="#local-6989586621681046242"><span class="hs-identifier hs-var hs-var">succ_counts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(BlockId -&gt; LabelMap Int -&gt; LabelMap Int)
-&gt; LabelMap Int -&gt; [BlockId] -&gt; LabelMap Int
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681046239"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681046239"><span class="hs-identifier hs-var">l</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(Int -&gt; Int -&gt; Int)
-&gt; KeyOf LabelMap -&gt; Int -&gt; LabelMap Int -&gt; LabelMap Int
forall (map :: * -&gt; *) a.
IsMap map =&gt;
(a -&gt; a -&gt; a) -&gt; KeyOf map -&gt; a -&gt; map a -&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapInsertWith"><span class="hs-identifier hs-var">mapInsertWith</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">(+)</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
BlockId
</span><a href="#local-6989586621681046239"><span class="hs-identifier hs-var">l</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">LabelMap Int
forall (map :: * -&gt; *) a. IsMap map =&gt; map a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapEmpty"><span class="hs-identifier hs-var">mapEmpty</span></a></span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681046241"><span class="hs-identifier hs-var">all_succs</span></a></span><span>
</span><span id="line-285"></span><span>
</span><span id="line-286"></span><span class="hs-comment">--</span><span>
</span><span id="line-287"></span><span class="hs-comment">-- filter the list of assignments to remove any assignments that</span><span>
</span><span id="line-288"></span><span class="hs-comment">-- are not live in a continuation.</span><span>
</span><span id="line-289"></span><span class="hs-comment">--</span><span>
</span><span id="line-290"></span><span class="annot"><a href="GHC.Cmm.Sink.html#filterAssignments"><span class="hs-identifier hs-type">filterAssignments</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#LocalRegSet"><span class="hs-identifier hs-type">LocalRegSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Sink.html#Assignments"><span class="hs-identifier hs-type">Assignments</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Sink.html#Assignments"><span class="hs-identifier hs-type">Assignments</span></a></span><span>
</span><span id="line-291"></span><span id="filterAssignments"><span class="annot"><span class="annottext">filterAssignments :: DynFlags -&gt; Set LocalReg -&gt; Assignments -&gt; Assignments
</span><a href="GHC.Cmm.Sink.html#filterAssignments"><span class="hs-identifier hs-var hs-var">filterAssignments</span></a></span></span><span> </span><span id="local-6989586621681046236"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046236"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681046235"><span class="annot"><span class="annottext">Set LocalReg
</span><a href="#local-6989586621681046235"><span class="hs-identifier hs-var">live</span></a></span></span><span> </span><span id="local-6989586621681046234"><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046234"><span class="hs-identifier hs-var">assigs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Assignments -&gt; Assignments
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#reverse"><span class="hs-identifier hs-var">reverse</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Assignments -&gt; Assignments -&gt; Assignments
</span><a href="#local-6989586621681046232"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046234"><span class="hs-identifier hs-var">assigs</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-292"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621681046232"><span class="annot"><span class="annottext">go :: Assignments -&gt; Assignments -&gt; Assignments
</span><a href="#local-6989586621681046232"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>             </span><span id="local-6989586621681046231"><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046231"><span class="hs-identifier hs-var">kept</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046231"><span class="hs-identifier hs-var">kept</span></a></span><span>
</span><span id="line-293"></span><span>        </span><span class="annot"><a href="#local-6989586621681046232"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681046230"><span class="annot"><span class="annottext">a :: Assignment
</span><a href="#local-6989586621681046230"><span class="hs-identifier hs-var">a</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span id="local-6989586621681046229"><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681046229"><span class="hs-identifier hs-var">r</span></a></span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">CmmExpr
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">AbsMem
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621681046228"><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046228"><span class="hs-keyword hs-var">as</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681046227"><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046227"><span class="hs-identifier hs-var">kept</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681046226"><span class="hs-identifier hs-var">needed</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Assignments -&gt; Assignments -&gt; Assignments
</span><a href="#local-6989586621681046232"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046228"><span class="hs-keyword hs-var">as</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Assignment
</span><a href="#local-6989586621681046230"><span class="hs-identifier hs-var">a</span></a></span><span class="annot"><span class="annottext">Assignment -&gt; Assignments -&gt; Assignments
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046227"><span class="hs-identifier hs-var">kept</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-294"></span><span>                               </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Assignments -&gt; Assignments -&gt; Assignments
</span><a href="#local-6989586621681046232"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046228"><span class="hs-keyword hs-var">as</span></a></span><span> </span><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046227"><span class="hs-identifier hs-var">kept</span></a></span><span>
</span><span id="line-295"></span><span>           </span><span class="hs-keyword">where</span><span>
</span><span id="line-296"></span><span>              </span><span id="local-6989586621681046226"><span class="annot"><span class="annottext">needed :: Bool
</span><a href="#local-6989586621681046226"><span class="hs-identifier hs-var hs-var">needed</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681046229"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg -&gt; Set LocalReg -&gt; Bool
forall a. Ord a =&gt; a -&gt; Set a -&gt; Bool
</span><a href="../../containers/src/Data.Set.Internal.html#member"><span class="hs-operator hs-var">`Set.member`</span></a></span><span> </span><span class="annot"><span class="annottext">Set LocalReg
</span><a href="#local-6989586621681046235"><span class="hs-identifier hs-var">live</span></a></span><span>
</span><span id="line-297"></span><span>                       </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">(CmmNode O O -&gt; Bool) -&gt; [CmmNode O O] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#any"><span class="hs-identifier hs-var">any</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; Assignment -&gt; CmmNode O O -&gt; Bool
forall (x :: Extensibility).
DynFlags -&gt; Assignment -&gt; CmmNode O x -&gt; Bool
</span><a href="GHC.Cmm.Sink.html#conflicts"><span class="hs-identifier hs-var">conflicts</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046236"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Assignment
</span><a href="#local-6989586621681046230"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Assignment -&gt; CmmNode O O) -&gt; Assignments -&gt; [CmmNode O O]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Assignment -&gt; CmmNode O O
</span><a href="GHC.Cmm.Sink.html#toNode"><span class="hs-identifier hs-var">toNode</span></a></span><span> </span><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046227"><span class="hs-identifier hs-var">kept</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-298"></span><span>                       </span><span class="hs-comment">--  Note that we must keep assignments that are</span><span>
</span><span id="line-299"></span><span>                       </span><span class="hs-comment">-- referred to by other assignments we have</span><span>
</span><span id="line-300"></span><span>                       </span><span class="hs-comment">-- already kept.</span><span>
</span><span id="line-301"></span><span>
</span><span id="line-302"></span><span class="hs-comment">-- -----------------------------------------------------------------------------</span><span>
</span><span id="line-303"></span><span class="hs-comment">-- Walk through the nodes of a block, sinking and inlining assignments</span><span>
</span><span id="line-304"></span><span class="hs-comment">-- as we go.</span><span>
</span><span id="line-305"></span><span class="hs-comment">--</span><span>
</span><span id="line-306"></span><span class="hs-comment">-- On input we pass in a:</span><span>
</span><span id="line-307"></span><span class="hs-comment">--    * list of nodes in the block</span><span>
</span><span id="line-308"></span><span class="hs-comment">--    * a list of assignments that appeared *before* this block and</span><span>
</span><span id="line-309"></span><span class="hs-comment">--      that are being sunk.</span><span>
</span><span id="line-310"></span><span class="hs-comment">--</span><span>
</span><span id="line-311"></span><span class="hs-comment">-- On output we get:</span><span>
</span><span id="line-312"></span><span class="hs-comment">--    * a new block</span><span>
</span><span id="line-313"></span><span class="hs-comment">--    * a list of assignments that will be placed *after* that block.</span><span>
</span><span id="line-314"></span><span class="hs-comment">--</span><span>
</span><span id="line-315"></span><span>
</span><span id="line-316"></span><span class="annot"><a href="GHC.Cmm.Sink.html#walk"><span class="hs-identifier hs-type">walk</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span>
</span><span id="line-317"></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Expr.html#LocalRegSet"><span class="hs-identifier hs-type">LocalRegSet</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Cmm.Node.html#CmmNode"><span class="hs-identifier hs-type">CmmNode</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Block.html#O"><span class="hs-identifier hs-type">O</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Block.html#O"><span class="hs-identifier hs-type">O</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>    </span><span class="hs-comment">-- nodes of the block, annotated with</span><span>
</span><span id="line-318"></span><span>                                        </span><span class="hs-comment">-- the set of registers live *after*</span><span>
</span><span id="line-319"></span><span>                                        </span><span class="hs-comment">-- this node.</span><span>
</span><span id="line-320"></span><span>
</span><span id="line-321"></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Sink.html#Assignments"><span class="hs-identifier hs-type">Assignments</span></a></span><span>                     </span><span class="hs-comment">-- The current list of</span><span>
</span><span id="line-322"></span><span>                                        </span><span class="hs-comment">-- assignments we are sinking.</span><span>
</span><span id="line-323"></span><span>                                        </span><span class="hs-comment">-- Earlier assignments may refer</span><span>
</span><span id="line-324"></span><span>                                        </span><span class="hs-comment">-- to later ones.</span><span>
</span><span id="line-325"></span><span>
</span><span id="line-326"></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Block.html#Block"><span class="hs-identifier hs-type">Block</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Node.html#CmmNode"><span class="hs-identifier hs-type">CmmNode</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Block.html#O"><span class="hs-identifier hs-type">O</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Block.html#O"><span class="hs-identifier hs-type">O</span></a></span><span>             </span><span class="hs-comment">-- The new block</span><span>
</span><span id="line-327"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Cmm.Sink.html#Assignments"><span class="hs-identifier hs-type">Assignments</span></a></span><span>                   </span><span class="hs-comment">-- Assignments to sink further</span><span>
</span><span id="line-328"></span><span>        </span><span class="hs-special">)</span><span>
</span><span id="line-329"></span><span>
</span><span id="line-330"></span><span id="walk"><span class="annot"><span class="annottext">walk :: DynFlags
-&gt; [(Set LocalReg, CmmNode O O)]
-&gt; Assignments
-&gt; (Block CmmNode O O, Assignments)
</span><a href="GHC.Cmm.Sink.html#walk"><span class="hs-identifier hs-var hs-var">walk</span></a></span></span><span> </span><span id="local-6989586621681046223"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046223"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681046222"><span class="annot"><span class="annottext">[(Set LocalReg, CmmNode O O)]
</span><a href="#local-6989586621681046222"><span class="hs-identifier hs-var">nodes</span></a></span></span><span> </span><span id="local-6989586621681046221"><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046221"><span class="hs-identifier hs-var">assigs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Set LocalReg, CmmNode O O)]
-&gt; Block CmmNode O O
-&gt; Assignments
-&gt; (Block CmmNode O O, Assignments)
</span><a href="#local-6989586621681046220"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[(Set LocalReg, CmmNode O O)]
</span><a href="#local-6989586621681046222"><span class="hs-identifier hs-var">nodes</span></a></span><span> </span><span class="annot"><span class="annottext">Block CmmNode O O
forall (n :: Extensibility -&gt; Extensibility -&gt; *). Block n O O
</span><a href="GHC.Cmm.Dataflow.Block.html#emptyBlock"><span class="hs-identifier hs-var">emptyBlock</span></a></span><span> </span><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046221"><span class="hs-identifier hs-var">assigs</span></a></span><span>
</span><span id="line-331"></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-332"></span><span>   </span><span id="local-6989586621681046220"><span class="annot"><span class="annottext">go :: [(Set LocalReg, CmmNode O O)]
-&gt; Block CmmNode O O
-&gt; Assignments
-&gt; (Block CmmNode O O, Assignments)
</span><a href="#local-6989586621681046220"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>               </span><span id="local-6989586621681046218"><span class="annot"><span class="annottext">Block CmmNode O O
</span><a href="#local-6989586621681046218"><span class="hs-identifier hs-var">block</span></a></span></span><span> </span><span id="local-6989586621681046217"><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046217"><span class="hs-keyword hs-var">as</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Block CmmNode O O
</span><a href="#local-6989586621681046218"><span class="hs-identifier hs-var">block</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046217"><span class="hs-keyword hs-var">as</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-333"></span><span>   </span><span class="annot"><a href="#local-6989586621681046220"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span id="local-6989586621681046216"><span class="annot"><span class="annottext">Set LocalReg
</span><a href="#local-6989586621681046216"><span class="hs-identifier hs-var">live</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681046215"><span class="annot"><span class="annottext">CmmNode O O
</span><a href="#local-6989586621681046215"><span class="hs-identifier hs-var">node</span></a></span></span><span class="hs-special">)</span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621681046214"><span class="annot"><span class="annottext">[(Set LocalReg, CmmNode O O)]
</span><a href="#local-6989586621681046214"><span class="hs-identifier hs-var">ns</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681046213"><span class="annot"><span class="annottext">Block CmmNode O O
</span><a href="#local-6989586621681046213"><span class="hs-identifier hs-var">block</span></a></span></span><span> </span><span id="local-6989586621681046212"><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046212"><span class="hs-keyword hs-var">as</span></a></span></span><span>
</span><span id="line-334"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CmmNode O O -&gt; Set LocalReg -&gt; Bool
forall (e :: Extensibility) (x :: Extensibility).
CmmNode e x -&gt; Set LocalReg -&gt; Bool
</span><a href="GHC.Cmm.Sink.html#shouldDiscard"><span class="hs-identifier hs-var">shouldDiscard</span></a></span><span> </span><span class="annot"><span class="annottext">CmmNode O O
</span><a href="#local-6989586621681046215"><span class="hs-identifier hs-var">node</span></a></span><span> </span><span class="annot"><span class="annottext">Set LocalReg
</span><a href="#local-6989586621681046216"><span class="hs-identifier hs-var">live</span></a></span><span>             </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Set LocalReg, CmmNode O O)]
-&gt; Block CmmNode O O
-&gt; Assignments
-&gt; (Block CmmNode O O, Assignments)
</span><a href="#local-6989586621681046220"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[(Set LocalReg, CmmNode O O)]
</span><a href="#local-6989586621681046214"><span class="hs-identifier hs-var">ns</span></a></span><span> </span><span class="annot"><span class="annottext">Block CmmNode O O
</span><a href="#local-6989586621681046213"><span class="hs-identifier hs-var">block</span></a></span><span> </span><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046212"><span class="hs-keyword hs-var">as</span></a></span><span>
</span><span id="line-335"></span><span>       </span><span class="hs-comment">-- discard dead assignment</span><span>
</span><span id="line-336"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681046210"><span class="annot"><span class="annottext">Assignment
</span><a href="#local-6989586621681046210"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; CmmNode O O -&gt; Maybe Assignment
forall (e :: Extensibility) (x :: Extensibility).
Platform -&gt; CmmNode e x -&gt; Maybe Assignment
</span><a href="GHC.Cmm.Sink.html#shouldSink"><span class="hs-identifier hs-var">shouldSink</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681046208"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">CmmNode O O
</span><a href="#local-6989586621681046207"><span class="hs-identifier hs-var">node2</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Set LocalReg, CmmNode O O)]
-&gt; Block CmmNode O O
-&gt; Assignments
-&gt; (Block CmmNode O O, Assignments)
</span><a href="#local-6989586621681046220"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[(Set LocalReg, CmmNode O O)]
</span><a href="#local-6989586621681046214"><span class="hs-identifier hs-var">ns</span></a></span><span> </span><span class="annot"><span class="annottext">Block CmmNode O O
</span><a href="#local-6989586621681046213"><span class="hs-identifier hs-var">block</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Assignment
</span><a href="#local-6989586621681046210"><span class="hs-identifier hs-var">a</span></a></span><span> </span><span class="annot"><span class="annottext">Assignment -&gt; Assignments -&gt; Assignments
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046206"><span class="hs-identifier hs-var">as1</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-337"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Set LocalReg, CmmNode O O)]
-&gt; Block CmmNode O O
-&gt; Assignments
-&gt; (Block CmmNode O O, Assignments)
</span><a href="#local-6989586621681046220"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[(Set LocalReg, CmmNode O O)]
</span><a href="#local-6989586621681046214"><span class="hs-identifier hs-var">ns</span></a></span><span> </span><span class="annot"><span class="annottext">Block CmmNode O O
</span><a href="#local-6989586621681046205"><span class="hs-identifier hs-var">block'</span></a></span><span> </span><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046204"><span class="hs-identifier hs-var">as'</span></a></span><span>
</span><span id="line-338"></span><span>    </span><span class="hs-keyword">where</span><span>
</span><span id="line-339"></span><span>      </span><span id="local-6989586621681046208"><span class="annot"><span class="annottext">platform :: Platform
</span><a href="#local-6989586621681046208"><span class="hs-identifier hs-var hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Platform
</span><a href="GHC.Driver.Session.html#targetPlatform"><span class="hs-identifier hs-var hs-var">targetPlatform</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046223"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-340"></span><span>      </span><span id="local-6989586621681046203"><span class="annot"><span class="annottext">node1 :: CmmNode O O
</span><a href="#local-6989586621681046203"><span class="hs-identifier hs-var hs-var">node1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; CmmNode O O -&gt; CmmNode O O
forall (e :: Extensibility) (x :: Extensibility).
Platform -&gt; CmmNode e x -&gt; CmmNode e x
</span><a href="GHC.Cmm.Opt.html#constantFoldNode"><span class="hs-identifier hs-var">constantFoldNode</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681046208"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">CmmNode O O
</span><a href="#local-6989586621681046215"><span class="hs-identifier hs-var">node</span></a></span><span>
</span><span id="line-341"></span><span>
</span><span id="line-342"></span><span>      </span><span class="hs-special">(</span><span id="local-6989586621681046207"><span class="annot"><span class="annottext">CmmNode O O
</span><a href="#local-6989586621681046207"><span class="hs-identifier hs-var">node2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681046206"><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046206"><span class="hs-identifier hs-var">as1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags
-&gt; Set LocalReg
-&gt; CmmNode O O
-&gt; Assignments
-&gt; (CmmNode O O, Assignments)
forall (x :: Extensibility).
DynFlags
-&gt; Set LocalReg
-&gt; CmmNode O x
-&gt; Assignments
-&gt; (CmmNode O x, Assignments)
</span><a href="GHC.Cmm.Sink.html#tryToInline"><span class="hs-identifier hs-var">tryToInline</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046223"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Set LocalReg
</span><a href="#local-6989586621681046216"><span class="hs-identifier hs-var">live</span></a></span><span> </span><span class="annot"><span class="annottext">CmmNode O O
</span><a href="#local-6989586621681046203"><span class="hs-identifier hs-var">node1</span></a></span><span> </span><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046212"><span class="hs-keyword hs-var">as</span></a></span><span>
</span><span id="line-343"></span><span>
</span><span id="line-344"></span><span>      </span><span class="hs-special">(</span><span id="local-6989586621681046202"><span class="annot"><span class="annottext">[CmmNode O O]
</span><a href="#local-6989586621681046202"><span class="hs-identifier hs-var">dropped</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681046204"><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046204"><span class="hs-identifier hs-var">as'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags
-&gt; (Assignment -&gt; Bool)
-&gt; Assignments
-&gt; ([CmmNode O O], Assignments)
</span><a href="GHC.Cmm.Sink.html#dropAssignmentsSimple"><span class="hs-identifier hs-var">dropAssignmentsSimple</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046223"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-345"></span><span>                          </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681046200"><span class="annot"><span class="annottext">Assignment
</span><a href="#local-6989586621681046200"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Assignment -&gt; CmmNode O O -&gt; Bool
forall (x :: Extensibility).
DynFlags -&gt; Assignment -&gt; CmmNode O x -&gt; Bool
</span><a href="GHC.Cmm.Sink.html#conflicts"><span class="hs-identifier hs-var">conflicts</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046223"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Assignment
</span><a href="#local-6989586621681046200"><span class="hs-identifier hs-var">a</span></a></span><span> </span><span class="annot"><span class="annottext">CmmNode O O
</span><a href="#local-6989586621681046207"><span class="hs-identifier hs-var">node2</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046206"><span class="hs-identifier hs-var">as1</span></a></span><span>
</span><span id="line-346"></span><span>
</span><span id="line-347"></span><span>      </span><span id="local-6989586621681046205"><span class="annot"><span class="annottext">block' :: Block CmmNode O O
</span><a href="#local-6989586621681046205"><span class="hs-identifier hs-var hs-var">block'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Block CmmNode O O -&gt; CmmNode O O -&gt; Block CmmNode O O)
-&gt; Block CmmNode O O -&gt; [CmmNode O O] -&gt; Block CmmNode O O
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="annot"><span class="annottext">Block CmmNode O O -&gt; CmmNode O O -&gt; Block CmmNode O O
forall (n :: Extensibility -&gt; Extensibility -&gt; *)
       (e :: Extensibility).
Block n e O -&gt; n O O -&gt; Block n e O
</span><a href="GHC.Cmm.Dataflow.Block.html#blockSnoc"><span class="hs-identifier hs-var">blockSnoc</span></a></span><span> </span><span class="annot"><span class="annottext">Block CmmNode O O
</span><a href="#local-6989586621681046213"><span class="hs-identifier hs-var">block</span></a></span><span> </span><span class="annot"><span class="annottext">[CmmNode O O]
</span><a href="#local-6989586621681046202"><span class="hs-identifier hs-var">dropped</span></a></span><span> </span><span class="annot"><span class="annottext">Block CmmNode O O -&gt; CmmNode O O -&gt; Block CmmNode O O
forall (n :: Extensibility -&gt; Extensibility -&gt; *)
       (e :: Extensibility).
Block n e O -&gt; n O O -&gt; Block n e O
</span><a href="GHC.Cmm.Dataflow.Block.html#blockSnoc"><span class="hs-operator hs-var">`blockSnoc`</span></a></span><span> </span><span class="annot"><span class="annottext">CmmNode O O
</span><a href="#local-6989586621681046207"><span class="hs-identifier hs-var">node2</span></a></span><span>
</span><span id="line-348"></span><span>
</span><span id="line-349"></span><span>
</span><span id="line-350"></span><span class="hs-comment">--</span><span>
</span><span id="line-351"></span><span class="hs-comment">-- Heuristic to decide whether to pick up and sink an assignment</span><span>
</span><span id="line-352"></span><span class="hs-comment">-- Currently we pick up all assignments to local registers.  It might</span><span>
</span><span id="line-353"></span><span class="hs-comment">-- be profitable to sink assignments to global regs too, but the</span><span>
</span><span id="line-354"></span><span class="hs-comment">-- liveness analysis doesn't track those (yet) so we can't.</span><span>
</span><span id="line-355"></span><span class="hs-comment">--</span><span>
</span><span id="line-356"></span><span id="local-6989586621681046477"><span id="local-6989586621681046478"><span class="annot"><a href="GHC.Cmm.Sink.html#shouldSink"><span class="hs-identifier hs-type">shouldSink</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#Platform"><span class="hs-identifier hs-type">Platform</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Node.html#CmmNode"><span class="hs-identifier hs-type">CmmNode</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681046478"><span class="hs-identifier hs-type">e</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681046477"><span class="hs-identifier hs-type">x</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Sink.html#Assignment"><span class="hs-identifier hs-type">Assignment</span></a></span></span></span><span>
</span><span id="line-357"></span><span id="shouldSink"><span class="annot"><span class="annottext">shouldSink :: forall (e :: Extensibility) (x :: Extensibility).
Platform -&gt; CmmNode e x -&gt; Maybe Assignment
</span><a href="GHC.Cmm.Sink.html#shouldSink"><span class="hs-identifier hs-var hs-var">shouldSink</span></a></span></span><span> </span><span id="local-6989586621681046199"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681046199"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Node.html#CmmAssign"><span class="hs-identifier hs-type">CmmAssign</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmLocal"><span class="hs-identifier hs-type">CmmLocal</span></a></span><span> </span><span id="local-6989586621681046195"><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681046195"><span class="hs-identifier hs-var">r</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681046194"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681046194"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681046193"><span class="hs-identifier hs-var">no_local_regs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Assignment -&gt; Maybe Assignment
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681046195"><span class="hs-identifier hs-var">r</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681046194"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; CmmExpr -&gt; AbsMem
</span><a href="GHC.Cmm.Sink.html#exprMem"><span class="hs-identifier hs-var">exprMem</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681046199"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681046194"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-358"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621681046193"><span class="annot"><span class="annottext">no_local_regs :: Bool
</span><a href="#local-6989586621681046193"><span class="hs-identifier hs-var hs-var">no_local_regs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="hs-comment">-- foldRegsUsed (\_ _ -&gt; False) True e</span><span>
</span><span id="line-359"></span><span class="annot"><a href="GHC.Cmm.Sink.html#shouldSink"><span class="hs-identifier hs-var">shouldSink</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681046191"><span class="annot"><span class="annottext">CmmNode e x
</span><a href="#local-6989586621681046191"><span class="hs-identifier hs-var">_other</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe Assignment
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-360"></span><span>
</span><span id="line-361"></span><span class="hs-comment">--</span><span>
</span><span id="line-362"></span><span class="hs-comment">-- discard dead assignments.  This doesn't do as good a job as</span><span>
</span><span id="line-363"></span><span class="hs-comment">-- removeDeadAssignments, because it would need multiple passes</span><span>
</span><span id="line-364"></span><span class="hs-comment">-- to get all the dead code, but it catches the common case of</span><span>
</span><span id="line-365"></span><span class="hs-comment">-- superfluous reloads from the stack that the stack allocator</span><span>
</span><span id="line-366"></span><span class="hs-comment">-- leaves behind.</span><span>
</span><span id="line-367"></span><span class="hs-comment">--</span><span>
</span><span id="line-368"></span><span class="hs-comment">-- Also we catch &quot;r = r&quot; here.  You might think it would fall</span><span>
</span><span id="line-369"></span><span class="hs-comment">-- out of inlining, but the inliner will see that r is live</span><span>
</span><span id="line-370"></span><span class="hs-comment">-- after the instruction and choose not to inline r in the rhs.</span><span>
</span><span id="line-371"></span><span class="hs-comment">--</span><span>
</span><span id="line-372"></span><span id="local-6989586621681046479"><span id="local-6989586621681046480"><span class="annot"><a href="GHC.Cmm.Sink.html#shouldDiscard"><span class="hs-identifier hs-type">shouldDiscard</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Node.html#CmmNode"><span class="hs-identifier hs-type">CmmNode</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681046480"><span class="hs-identifier hs-type">e</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681046479"><span class="hs-identifier hs-type">x</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#LocalRegSet"><span class="hs-identifier hs-type">LocalRegSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span></span></span><span>
</span><span id="line-373"></span><span id="shouldDiscard"><span class="annot"><span class="annottext">shouldDiscard :: forall (e :: Extensibility) (x :: Extensibility).
CmmNode e x -&gt; Set LocalReg -&gt; Bool
</span><a href="GHC.Cmm.Sink.html#shouldDiscard"><span class="hs-identifier hs-var hs-var">shouldDiscard</span></a></span></span><span> </span><span id="local-6989586621681046190"><span class="annot"><span class="annottext">CmmNode e x
</span><a href="#local-6989586621681046190"><span class="hs-identifier hs-var">node</span></a></span></span><span> </span><span id="local-6989586621681046189"><span class="annot"><span class="annottext">Set LocalReg
</span><a href="#local-6989586621681046189"><span class="hs-identifier hs-var">live</span></a></span></span><span>
</span><span id="line-374"></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">CmmNode e x
</span><a href="#local-6989586621681046190"><span class="hs-identifier hs-var">node</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-375"></span><span>       </span><span class="annot"><a href="GHC.Cmm.Node.html#CmmAssign"><span class="hs-identifier hs-type">CmmAssign</span></a></span><span> </span><span id="local-6989586621681046184"><span class="annot"><span class="annottext">CmmReg
</span><a href="#local-6989586621681046184"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmReg"><span class="hs-identifier hs-type">CmmReg</span></a></span><span> </span><span id="local-6989586621681046183"><span class="annot"><span class="annottext">CmmReg
</span><a href="#local-6989586621681046183"><span class="hs-identifier hs-var">r'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CmmReg
</span><a href="#local-6989586621681046184"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReg -&gt; CmmReg -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">CmmReg
</span><a href="#local-6989586621681046183"><span class="hs-identifier hs-var">r'</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-376"></span><span>       </span><span class="annot"><a href="GHC.Cmm.Node.html#CmmAssign"><span class="hs-identifier hs-type">CmmAssign</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmLocal"><span class="hs-identifier hs-type">CmmLocal</span></a></span><span> </span><span id="local-6989586621681046179"><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681046179"><span class="hs-identifier hs-var">r</span></a></span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681046179"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg -&gt; Set LocalReg -&gt; Bool
forall a. Ord a =&gt; a -&gt; Set a -&gt; Bool
</span><a href="../../containers/src/Data.Set.Internal.html#member"><span class="hs-operator hs-var">`Set.member`</span></a></span><span> </span><span class="annot"><span class="annottext">Set LocalReg
</span><a href="#local-6989586621681046189"><span class="hs-identifier hs-var">live</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-377"></span><span>       </span><span id="local-6989586621681046178"><span class="annot"><span class="annottext">CmmNode e x
</span><a href="#local-6989586621681046178"><span class="hs-identifier hs-var">_otherwise</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-378"></span><span>
</span><span id="line-379"></span><span>
</span><span id="line-380"></span><span class="annot"><a href="GHC.Cmm.Sink.html#toNode"><span class="hs-identifier hs-type">toNode</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Sink.html#Assignment"><span class="hs-identifier hs-type">Assignment</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Node.html#CmmNode"><span class="hs-identifier hs-type">CmmNode</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Block.html#O"><span class="hs-identifier hs-type">O</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Block.html#O"><span class="hs-identifier hs-type">O</span></a></span><span>
</span><span id="line-381"></span><span id="toNode"><span class="annot"><span class="annottext">toNode :: Assignment -&gt; CmmNode O O
</span><a href="GHC.Cmm.Sink.html#toNode"><span class="hs-identifier hs-var hs-var">toNode</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681046177"><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681046177"><span class="hs-identifier hs-var">r</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681046176"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681046176"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">AbsMem
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr -&gt; CmmNode O O
</span><a href="GHC.Cmm.Node.html#CmmAssign"><span class="hs-identifier hs-var">CmmAssign</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LocalReg -&gt; CmmReg
</span><a href="GHC.Cmm.Expr.html#CmmLocal"><span class="hs-identifier hs-var">CmmLocal</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681046177"><span class="hs-identifier hs-var">r</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681046176"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-382"></span><span>
</span><span id="line-383"></span><span class="annot"><a href="GHC.Cmm.Sink.html#dropAssignmentsSimple"><span class="hs-identifier hs-type">dropAssignmentsSimple</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Sink.html#Assignment"><span class="hs-identifier hs-type">Assignment</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Sink.html#Assignments"><span class="hs-identifier hs-type">Assignments</span></a></span><span>
</span><span id="line-384"></span><span>                      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.Node.html#CmmNode"><span class="hs-identifier hs-type">CmmNode</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Block.html#O"><span class="hs-identifier hs-type">O</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Block.html#O"><span class="hs-identifier hs-type">O</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Cmm.Sink.html#Assignments"><span class="hs-identifier hs-type">Assignments</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-385"></span><span id="dropAssignmentsSimple"><span class="annot"><span class="annottext">dropAssignmentsSimple :: DynFlags
-&gt; (Assignment -&gt; Bool)
-&gt; Assignments
-&gt; ([CmmNode O O], Assignments)
</span><a href="GHC.Cmm.Sink.html#dropAssignmentsSimple"><span class="hs-identifier hs-var hs-var">dropAssignmentsSimple</span></a></span></span><span> </span><span id="local-6989586621681046175"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046175"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681046174"><span class="annot"><span class="annottext">Assignment -&gt; Bool
</span><a href="#local-6989586621681046174"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags
-&gt; (Assignment -&gt; () -&gt; (Bool, ()))
-&gt; ()
-&gt; Assignments
-&gt; ([CmmNode O O], Assignments)
forall s.
DynFlags
-&gt; (Assignment -&gt; s -&gt; (Bool, s))
-&gt; s
-&gt; Assignments
-&gt; ([CmmNode O O], Assignments)
</span><a href="GHC.Cmm.Sink.html#dropAssignments"><span class="hs-identifier hs-var">dropAssignments</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046175"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681046173"><span class="annot"><span class="annottext">Assignment
</span><a href="#local-6989586621681046173"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span class="annot"><span class="annottext">()
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Assignment -&gt; Bool
</span><a href="#local-6989586621681046174"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">Assignment
</span><a href="#local-6989586621681046173"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-386"></span><span>
</span><span id="line-387"></span><span id="local-6989586621681046516"><span class="annot"><a href="GHC.Cmm.Sink.html#dropAssignments"><span class="hs-identifier hs-type">dropAssignments</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Sink.html#Assignment"><span class="hs-identifier hs-type">Assignment</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621681046516"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="#local-6989586621681046516"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621681046516"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Sink.html#Assignments"><span class="hs-identifier hs-type">Assignments</span></a></span><span>
</span><span id="line-388"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.Node.html#CmmNode"><span class="hs-identifier hs-type">CmmNode</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Block.html#O"><span class="hs-identifier hs-type">O</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Block.html#O"><span class="hs-identifier hs-type">O</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Cmm.Sink.html#Assignments"><span class="hs-identifier hs-type">Assignments</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-389"></span><span id="dropAssignments"><span class="annot"><span class="annottext">dropAssignments :: forall s.
DynFlags
-&gt; (Assignment -&gt; s -&gt; (Bool, s))
-&gt; s
-&gt; Assignments
-&gt; ([CmmNode O O], Assignments)
</span><a href="GHC.Cmm.Sink.html#dropAssignments"><span class="hs-identifier hs-var hs-var">dropAssignments</span></a></span></span><span> </span><span id="local-6989586621681046171"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046171"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681046170"><span class="annot"><span class="annottext">Assignment -&gt; s -&gt; (Bool, s)
</span><a href="#local-6989586621681046170"><span class="hs-identifier hs-var">should_drop</span></a></span></span><span> </span><span id="local-6989586621681046169"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621681046169"><span class="hs-identifier hs-var">state</span></a></span></span><span> </span><span id="local-6989586621681046168"><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046168"><span class="hs-identifier hs-var">assigs</span></a></span></span><span>
</span><span id="line-390"></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[CmmNode O O]
</span><a href="#local-6989586621681046167"><span class="hs-identifier hs-var">dropped</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Assignments -&gt; Assignments
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#reverse"><span class="hs-identifier hs-var">reverse</span></a></span><span> </span><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046166"><span class="hs-identifier hs-var">kept</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-391"></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-392"></span><span>   </span><span class="hs-special">(</span><span id="local-6989586621681046167"><span class="annot"><span class="annottext">[CmmNode O O]
</span><a href="#local-6989586621681046167"><span class="hs-identifier hs-var">dropped</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681046166"><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046166"><span class="hs-identifier hs-var">kept</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">s
-&gt; Assignments
-&gt; [CmmNode O O]
-&gt; Assignments
-&gt; ([CmmNode O O], Assignments)
</span><a href="#local-6989586621681046165"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621681046169"><span class="hs-identifier hs-var">state</span></a></span><span> </span><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046168"><span class="hs-identifier hs-var">assigs</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-393"></span><span>
</span><span id="line-394"></span><span>   </span><span id="local-6989586621681046165"><span class="annot"><span class="annottext">go :: s
-&gt; Assignments
-&gt; [CmmNode O O]
-&gt; Assignments
-&gt; ([CmmNode O O], Assignments)
</span><a href="#local-6989586621681046165"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="annot"><span class="annottext">s
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>             </span><span id="local-6989586621681046164"><span class="annot"><span class="annottext">[CmmNode O O]
</span><a href="#local-6989586621681046164"><span class="hs-identifier hs-var">dropped</span></a></span></span><span> </span><span id="local-6989586621681046163"><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046163"><span class="hs-identifier hs-var">kept</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[CmmNode O O]
</span><a href="#local-6989586621681046164"><span class="hs-identifier hs-var">dropped</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046163"><span class="hs-identifier hs-var">kept</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-395"></span><span>   </span><span class="annot"><a href="#local-6989586621681046165"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681046162"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621681046162"><span class="hs-identifier hs-var">state</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681046161"><span class="annot"><span class="annottext">Assignment
</span><a href="#local-6989586621681046161"><span class="hs-identifier hs-var">assig</span></a></span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621681046160"><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046160"><span class="hs-identifier hs-var">rest</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681046159"><span class="annot"><span class="annottext">[CmmNode O O]
</span><a href="#local-6989586621681046159"><span class="hs-identifier hs-var">dropped</span></a></span></span><span> </span><span id="local-6989586621681046158"><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046158"><span class="hs-identifier hs-var">kept</span></a></span></span><span>
</span><span id="line-396"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681046157"><span class="hs-identifier hs-var">conflict</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">s
-&gt; Assignments
-&gt; [CmmNode O O]
-&gt; Assignments
-&gt; ([CmmNode O O], Assignments)
</span><a href="#local-6989586621681046165"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621681046156"><span class="hs-identifier hs-var">state'</span></a></span><span> </span><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046160"><span class="hs-identifier hs-var">rest</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Assignment -&gt; CmmNode O O
</span><a href="GHC.Cmm.Sink.html#toNode"><span class="hs-identifier hs-var">toNode</span></a></span><span> </span><span class="annot"><span class="annottext">Assignment
</span><a href="#local-6989586621681046161"><span class="hs-identifier hs-var">assig</span></a></span><span> </span><span class="annot"><span class="annottext">CmmNode O O -&gt; [CmmNode O O] -&gt; [CmmNode O O]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[CmmNode O O]
</span><a href="#local-6989586621681046159"><span class="hs-identifier hs-var">dropped</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046158"><span class="hs-identifier hs-var">kept</span></a></span><span>
</span><span id="line-397"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">s
-&gt; Assignments
-&gt; [CmmNode O O]
-&gt; Assignments
-&gt; ([CmmNode O O], Assignments)
</span><a href="#local-6989586621681046165"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621681046156"><span class="hs-identifier hs-var">state'</span></a></span><span> </span><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046160"><span class="hs-identifier hs-var">rest</span></a></span><span> </span><span class="annot"><span class="annottext">[CmmNode O O]
</span><a href="#local-6989586621681046159"><span class="hs-identifier hs-var">dropped</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Assignment
</span><a href="#local-6989586621681046161"><span class="hs-identifier hs-var">assig</span></a></span><span class="annot"><span class="annottext">Assignment -&gt; Assignments -&gt; Assignments
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046158"><span class="hs-identifier hs-var">kept</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-398"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-399"></span><span>        </span><span class="hs-special">(</span><span id="local-6989586621681046155"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681046155"><span class="hs-identifier hs-var">dropit</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681046156"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621681046156"><span class="hs-identifier hs-var">state'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Assignment -&gt; s -&gt; (Bool, s)
</span><a href="#local-6989586621681046170"><span class="hs-identifier hs-var">should_drop</span></a></span><span> </span><span class="annot"><span class="annottext">Assignment
</span><a href="#local-6989586621681046161"><span class="hs-identifier hs-var">assig</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621681046162"><span class="hs-identifier hs-var">state</span></a></span><span>
</span><span id="line-400"></span><span>        </span><span id="local-6989586621681046157"><span class="annot"><span class="annottext">conflict :: Bool
</span><a href="#local-6989586621681046157"><span class="hs-identifier hs-var hs-var">conflict</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681046155"><span class="hs-identifier hs-var">dropit</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">(CmmNode O O -&gt; Bool) -&gt; [CmmNode O O] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#any"><span class="hs-identifier hs-var">any</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; Assignment -&gt; CmmNode O O -&gt; Bool
forall (x :: Extensibility).
DynFlags -&gt; Assignment -&gt; CmmNode O x -&gt; Bool
</span><a href="GHC.Cmm.Sink.html#conflicts"><span class="hs-identifier hs-var">conflicts</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046171"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Assignment
</span><a href="#local-6989586621681046161"><span class="hs-identifier hs-var">assig</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[CmmNode O O]
</span><a href="#local-6989586621681046159"><span class="hs-identifier hs-var">dropped</span></a></span><span>
</span><span id="line-401"></span><span>
</span><span id="line-402"></span><span>
</span><span id="line-403"></span><span class="hs-comment">-- -----------------------------------------------------------------------------</span><span>
</span><span id="line-404"></span><span class="hs-comment">-- Try to inline assignments into a node.</span><span>
</span><span id="line-405"></span><span class="hs-comment">-- This also does constant folding for primpops, since</span><span>
</span><span id="line-406"></span><span class="hs-comment">-- inlining opens up opportunities for doing so.</span><span>
</span><span id="line-407"></span><span>
</span><span id="line-408"></span><span id="local-6989586621681046523"><span class="annot"><a href="GHC.Cmm.Sink.html#tryToInline"><span class="hs-identifier hs-type">tryToInline</span></a></span><span>
</span><span id="line-409"></span><span>   </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span>
</span><span id="line-410"></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#LocalRegSet"><span class="hs-identifier hs-type">LocalRegSet</span></a></span><span>               </span><span class="hs-comment">-- set of registers live after this</span><span>
</span><span id="line-411"></span><span>                                </span><span class="hs-comment">-- node.  We cannot inline anything</span><span>
</span><span id="line-412"></span><span>                                </span><span class="hs-comment">-- that is live after the node, unless</span><span>
</span><span id="line-413"></span><span>                                </span><span class="hs-comment">-- it is small enough to duplicate.</span><span>
</span><span id="line-414"></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Node.html#CmmNode"><span class="hs-identifier hs-type">CmmNode</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Block.html#O"><span class="hs-identifier hs-type">O</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681046523"><span class="hs-identifier hs-type">x</span></a></span><span>               </span><span class="hs-comment">-- The node to inline into</span><span>
</span><span id="line-415"></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Sink.html#Assignments"><span class="hs-identifier hs-type">Assignments</span></a></span><span>               </span><span class="hs-comment">-- Assignments to inline</span><span>
</span><span id="line-416"></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-417"></span><span>        </span><span class="annot"><a href="GHC.Cmm.Node.html#CmmNode"><span class="hs-identifier hs-type">CmmNode</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Block.html#O"><span class="hs-identifier hs-type">O</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681046523"><span class="hs-identifier hs-type">x</span></a></span><span>             </span><span class="hs-comment">-- New node</span><span>
</span><span id="line-418"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Cmm.Sink.html#Assignments"><span class="hs-identifier hs-type">Assignments</span></a></span><span>             </span><span class="hs-comment">-- Remaining assignments</span><span>
</span><span id="line-419"></span><span>      </span><span class="hs-special">)</span></span><span>
</span><span id="line-420"></span><span>
</span><span id="line-421"></span><span id="tryToInline"><span class="annot"><span class="annottext">tryToInline :: forall (x :: Extensibility).
DynFlags
-&gt; Set LocalReg
-&gt; CmmNode O x
-&gt; Assignments
-&gt; (CmmNode O x, Assignments)
</span><a href="GHC.Cmm.Sink.html#tryToInline"><span class="hs-identifier hs-var hs-var">tryToInline</span></a></span></span><span> </span><span id="local-6989586621681046140"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046140"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681046139"><span class="annot"><span class="annottext">Set LocalReg
</span><a href="#local-6989586621681046139"><span class="hs-identifier hs-var">live</span></a></span></span><span> </span><span id="local-6989586621681046138"><span class="annot"><span class="annottext">CmmNode O x
</span><a href="#local-6989586621681046138"><span class="hs-identifier hs-var">node</span></a></span></span><span> </span><span id="local-6989586621681046137"><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046137"><span class="hs-identifier hs-var">assigs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UniqFM LocalReg Int
-&gt; CmmNode O x
-&gt; LRegSet
-&gt; Assignments
-&gt; (CmmNode O x, Assignments)
</span><a href="#local-6989586621681046136"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">UniqFM LocalReg Int
</span><a href="#local-6989586621681046135"><span class="hs-identifier hs-var">usages</span></a></span><span> </span><span class="annot"><span class="annottext">CmmNode O x
</span><a href="#local-6989586621681046138"><span class="hs-identifier hs-var">node</span></a></span><span> </span><span class="annot"><span class="annottext">LRegSet
</span><a href="GHC.Cmm.Sink.html#emptyLRegSet"><span class="hs-identifier hs-var">emptyLRegSet</span></a></span><span> </span><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046137"><span class="hs-identifier hs-var">assigs</span></a></span><span>
</span><span id="line-422"></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-423"></span><span>  </span><span class="annot"><a href="#local-6989586621681046135"><span class="hs-identifier hs-type">usages</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Unique.FM.html#UniqFM"><span class="hs-identifier hs-type">UniqFM</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#LocalReg"><span class="hs-identifier hs-type">LocalReg</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-comment">-- Maps each LocalReg to a count of how often it is used</span><span>
</span><span id="line-424"></span><span>  </span><span id="local-6989586621681046135"><span class="annot"><span class="annottext">usages :: UniqFM LocalReg Int
</span><a href="#local-6989586621681046135"><span class="hs-identifier hs-var hs-var">usages</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags
-&gt; (UniqFM LocalReg Int -&gt; LocalReg -&gt; UniqFM LocalReg Int)
-&gt; UniqFM LocalReg Int
-&gt; CmmNode O x
-&gt; UniqFM LocalReg Int
forall a b.
UserOfRegs LocalReg a =&gt;
DynFlags -&gt; (b -&gt; LocalReg -&gt; b) -&gt; b -&gt; a -&gt; b
</span><a href="GHC.Cmm.Expr.html#foldLocalRegsUsed"><span class="hs-identifier hs-var">foldLocalRegsUsed</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046140"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">UniqFM LocalReg Int -&gt; LocalReg -&gt; UniqFM LocalReg Int
</span><a href="GHC.Cmm.Sink.html#addUsage"><span class="hs-identifier hs-var">addUsage</span></a></span><span> </span><span class="annot"><span class="annottext">UniqFM LocalReg Int
forall key elt. UniqFM key elt
</span><a href="GHC.Types.Unique.FM.html#emptyUFM"><span class="hs-identifier hs-var">emptyUFM</span></a></span><span> </span><span class="annot"><span class="annottext">CmmNode O x
</span><a href="#local-6989586621681046138"><span class="hs-identifier hs-var">node</span></a></span><span>
</span><span id="line-425"></span><span>
</span><span id="line-426"></span><span>  </span><span id="local-6989586621681046136"><span class="annot"><span class="annottext">go :: UniqFM LocalReg Int
-&gt; CmmNode O x
-&gt; LRegSet
-&gt; Assignments
-&gt; (CmmNode O x, Assignments)
</span><a href="#local-6989586621681046136"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621681046131"><span class="annot"><span class="annottext">UniqFM LocalReg Int
</span><a href="#local-6989586621681046131"><span class="hs-identifier hs-var">_usages</span></a></span></span><span> </span><span id="local-6989586621681046130"><span class="annot"><span class="annottext">CmmNode O x
</span><a href="#local-6989586621681046130"><span class="hs-identifier hs-var">node</span></a></span></span><span> </span><span id="local-6989586621681046129"><span class="annot"><span class="annottext">LRegSet
</span><a href="#local-6989586621681046129"><span class="hs-identifier hs-var">_skipped</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmNode O x
</span><a href="#local-6989586621681046130"><span class="hs-identifier hs-var">node</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-427"></span><span>
</span><span id="line-428"></span><span>  </span><span class="annot"><a href="#local-6989586621681046136"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681046128"><span class="annot"><span class="annottext">UniqFM LocalReg Int
</span><a href="#local-6989586621681046128"><span class="hs-identifier hs-var">usages</span></a></span></span><span> </span><span id="local-6989586621681046127"><span class="annot"><span class="annottext">CmmNode O x
</span><a href="#local-6989586621681046127"><span class="hs-identifier hs-var">node</span></a></span></span><span> </span><span id="local-6989586621681046126"><span class="annot"><span class="annottext">LRegSet
</span><a href="#local-6989586621681046126"><span class="hs-identifier hs-var">skipped</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681046125"><span class="annot"><span class="annottext">a :: Assignment
</span><a href="#local-6989586621681046125"><span class="hs-identifier hs-var">a</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span id="local-6989586621681046124"><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681046124"><span class="hs-identifier hs-var">l</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681046123"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681046123"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">AbsMem
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621681046122"><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046122"><span class="hs-identifier hs-var">rest</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-429"></span><span>   </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681046121"><span class="hs-identifier hs-var">cannot_inline</span></a></span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CmmNode O x, Assignments)
</span><a href="#local-6989586621681046120"><span class="hs-identifier hs-var">dont_inline</span></a></span><span>
</span><span id="line-430"></span><span>   </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681046119"><span class="hs-identifier hs-var">occurs_none</span></a></span><span>             </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CmmNode O x, Assignments)
</span><a href="#local-6989586621681046118"><span class="hs-identifier hs-var">discard</span></a></span><span>  </span><span class="hs-comment">-- Note [discard during inlining]</span><span>
</span><span id="line-431"></span><span>   </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681046117"><span class="hs-identifier hs-var">occurs_once</span></a></span><span>             </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CmmNode O x, Assignments)
</span><a href="#local-6989586621681046116"><span class="hs-identifier hs-var">inline_and_discard</span></a></span><span>
</span><span id="line-432"></span><span>   </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; CmmExpr -&gt; Bool
</span><a href="GHC.Cmm.Sink.html#isTrivial"><span class="hs-identifier hs-var">isTrivial</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046140"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681046123"><span class="hs-identifier hs-var">rhs</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CmmNode O x, Assignments)
</span><a href="#local-6989586621681046115"><span class="hs-identifier hs-var">inline_and_keep</span></a></span><span>
</span><span id="line-433"></span><span>   </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>               </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CmmNode O x, Assignments)
</span><a href="#local-6989586621681046120"><span class="hs-identifier hs-var">dont_inline</span></a></span><span>
</span><span id="line-434"></span><span>   </span><span class="hs-keyword">where</span><span>
</span><span id="line-435"></span><span>        </span><span id="local-6989586621681046114"><span class="annot"><span class="annottext">platform :: Platform
</span><a href="#local-6989586621681046114"><span class="hs-identifier hs-var hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Platform
</span><a href="GHC.Driver.Session.html#targetPlatform"><span class="hs-identifier hs-var hs-var">targetPlatform</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046140"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-436"></span><span>        </span><span id="local-6989586621681046116"><span class="annot"><span class="annottext">inline_and_discard :: (CmmNode O x, Assignments)
</span><a href="#local-6989586621681046116"><span class="hs-identifier hs-var hs-var">inline_and_discard</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UniqFM LocalReg Int
-&gt; CmmNode O x
-&gt; LRegSet
-&gt; Assignments
-&gt; (CmmNode O x, Assignments)
</span><a href="#local-6989586621681046136"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">UniqFM LocalReg Int
</span><a href="#local-6989586621681046113"><span class="hs-identifier hs-var">usages'</span></a></span><span> </span><span class="annot"><span class="annottext">CmmNode O x
</span><a href="#local-6989586621681046112"><span class="hs-identifier hs-var">inl_node</span></a></span><span> </span><span class="annot"><span class="annottext">LRegSet
</span><a href="#local-6989586621681046126"><span class="hs-identifier hs-var">skipped</span></a></span><span> </span><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046122"><span class="hs-identifier hs-var">rest</span></a></span><span>
</span><span id="line-437"></span><span>          </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621681046113"><span class="annot"><span class="annottext">usages' :: UniqFM LocalReg Int
</span><a href="#local-6989586621681046113"><span class="hs-identifier hs-var hs-var">usages'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags
-&gt; (UniqFM LocalReg Int -&gt; LocalReg -&gt; UniqFM LocalReg Int)
-&gt; UniqFM LocalReg Int
-&gt; CmmExpr
-&gt; UniqFM LocalReg Int
forall a b.
UserOfRegs LocalReg a =&gt;
DynFlags -&gt; (b -&gt; LocalReg -&gt; b) -&gt; b -&gt; a -&gt; b
</span><a href="GHC.Cmm.Expr.html#foldLocalRegsUsed"><span class="hs-identifier hs-var">foldLocalRegsUsed</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046140"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">UniqFM LocalReg Int -&gt; LocalReg -&gt; UniqFM LocalReg Int
</span><a href="GHC.Cmm.Sink.html#addUsage"><span class="hs-identifier hs-var">addUsage</span></a></span><span> </span><span class="annot"><span class="annottext">UniqFM LocalReg Int
</span><a href="#local-6989586621681046128"><span class="hs-identifier hs-var">usages</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681046123"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-438"></span><span>
</span><span id="line-439"></span><span>        </span><span id="local-6989586621681046118"><span class="annot"><span class="annottext">discard :: (CmmNode O x, Assignments)
</span><a href="#local-6989586621681046118"><span class="hs-identifier hs-var hs-var">discard</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UniqFM LocalReg Int
-&gt; CmmNode O x
-&gt; LRegSet
-&gt; Assignments
-&gt; (CmmNode O x, Assignments)
</span><a href="#local-6989586621681046136"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">UniqFM LocalReg Int
</span><a href="#local-6989586621681046128"><span class="hs-identifier hs-var">usages</span></a></span><span> </span><span class="annot"><span class="annottext">CmmNode O x
</span><a href="#local-6989586621681046127"><span class="hs-identifier hs-var">node</span></a></span><span> </span><span class="annot"><span class="annottext">LRegSet
</span><a href="#local-6989586621681046126"><span class="hs-identifier hs-var">skipped</span></a></span><span> </span><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046122"><span class="hs-identifier hs-var">rest</span></a></span><span>
</span><span id="line-440"></span><span>
</span><span id="line-441"></span><span>        </span><span id="local-6989586621681046120"><span class="annot"><span class="annottext">dont_inline :: (CmmNode O x, Assignments)
</span><a href="#local-6989586621681046120"><span class="hs-identifier hs-var hs-var">dont_inline</span></a></span></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CmmNode O x -&gt; (CmmNode O x, Assignments)
</span><a href="#local-6989586621681046111"><span class="hs-identifier hs-var">keep</span></a></span><span> </span><span class="annot"><span class="annottext">CmmNode O x
</span><a href="#local-6989586621681046127"><span class="hs-identifier hs-var">node</span></a></span><span>  </span><span class="hs-comment">-- don't inline the assignment, keep it</span><span>
</span><span id="line-442"></span><span>        </span><span id="local-6989586621681046115"><span class="annot"><span class="annottext">inline_and_keep :: (CmmNode O x, Assignments)
</span><a href="#local-6989586621681046115"><span class="hs-identifier hs-var hs-var">inline_and_keep</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CmmNode O x -&gt; (CmmNode O x, Assignments)
</span><a href="#local-6989586621681046111"><span class="hs-identifier hs-var">keep</span></a></span><span> </span><span class="annot"><span class="annottext">CmmNode O x
</span><a href="#local-6989586621681046112"><span class="hs-identifier hs-var">inl_node</span></a></span><span> </span><span class="hs-comment">-- inline the assignment, keep it</span><span>
</span><span id="line-443"></span><span>
</span><span id="line-444"></span><span>        </span><span id="local-6989586621681046111"><span class="annot"><span class="annottext">keep :: CmmNode O x -&gt; (CmmNode O x, Assignments)
</span><a href="#local-6989586621681046111"><span class="hs-identifier hs-var hs-var">keep</span></a></span></span><span> </span><span id="local-6989586621681046110"><span class="annot"><span class="annottext">CmmNode O x
</span><a href="#local-6989586621681046110"><span class="hs-identifier hs-var">node'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmNode O x
</span><a href="#local-6989586621681046109"><span class="hs-identifier hs-var">final_node</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Assignment
</span><a href="#local-6989586621681046125"><span class="hs-identifier hs-var">a</span></a></span><span> </span><span class="annot"><span class="annottext">Assignment -&gt; Assignments -&gt; Assignments
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046108"><span class="hs-identifier hs-var">rest'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-445"></span><span>          </span><span class="hs-keyword">where</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681046109"><span class="annot"><span class="annottext">CmmNode O x
</span><a href="#local-6989586621681046109"><span class="hs-identifier hs-var">final_node</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681046108"><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046108"><span class="hs-identifier hs-var">rest'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UniqFM LocalReg Int
-&gt; CmmNode O x
-&gt; LRegSet
-&gt; Assignments
-&gt; (CmmNode O x, Assignments)
</span><a href="#local-6989586621681046136"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">UniqFM LocalReg Int
</span><a href="#local-6989586621681046107"><span class="hs-identifier hs-var">usages'</span></a></span><span> </span><span class="annot"><span class="annottext">CmmNode O x
</span><a href="#local-6989586621681046110"><span class="hs-identifier hs-var">node'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LocalReg -&gt; LRegSet -&gt; LRegSet
</span><a href="GHC.Cmm.Sink.html#insertLRegSet"><span class="hs-identifier hs-var">insertLRegSet</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681046124"><span class="hs-identifier hs-var">l</span></a></span><span> </span><span class="annot"><span class="annottext">LRegSet
</span><a href="#local-6989586621681046126"><span class="hs-identifier hs-var">skipped</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Assignments
</span><a href="#local-6989586621681046122"><span class="hs-identifier hs-var">rest</span></a></span><span>
</span><span id="line-446"></span><span>                </span><span id="local-6989586621681046107"><span class="annot"><span class="annottext">usages' :: UniqFM LocalReg Int
</span><a href="#local-6989586621681046107"><span class="hs-identifier hs-var hs-var">usages'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags
-&gt; (UniqFM LocalReg Int -&gt; LocalReg -&gt; UniqFM LocalReg Int)
-&gt; UniqFM LocalReg Int
-&gt; CmmExpr
-&gt; UniqFM LocalReg Int
forall a b.
UserOfRegs LocalReg a =&gt;
DynFlags -&gt; (b -&gt; LocalReg -&gt; b) -&gt; b -&gt; a -&gt; b
</span><a href="GHC.Cmm.Expr.html#foldLocalRegsUsed"><span class="hs-identifier hs-var">foldLocalRegsUsed</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046140"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681046106"><span class="annot"><span class="annottext">UniqFM LocalReg Int
</span><a href="#local-6989586621681046106"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621681046105"><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681046105"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">UniqFM LocalReg Int -&gt; LocalReg -&gt; Int -&gt; UniqFM LocalReg Int
forall key elt.
Uniquable key =&gt;
UniqFM key elt -&gt; key -&gt; elt -&gt; UniqFM key elt
</span><a href="GHC.Types.Unique.FM.html#addToUFM"><span class="hs-identifier hs-var">addToUFM</span></a></span><span> </span><span class="annot"><span class="annottext">UniqFM LocalReg Int
</span><a href="#local-6989586621681046106"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681046105"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span class="hs-special">)</span><span>
</span><span id="line-447"></span><span>                                            </span><span class="annot"><span class="annottext">UniqFM LocalReg Int
</span><a href="#local-6989586621681046128"><span class="hs-identifier hs-var">usages</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681046123"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-448"></span><span>                </span><span class="hs-comment">-- we must not inline anything that is mentioned in the RHS</span><span>
</span><span id="line-449"></span><span>                </span><span class="hs-comment">-- of a binding that we have already skipped, so we set the</span><span>
</span><span id="line-450"></span><span>                </span><span class="hs-comment">-- usages of the regs on the RHS to 2.</span><span>
</span><span id="line-451"></span><span>
</span><span id="line-452"></span><span>        </span><span id="local-6989586621681046121"><span class="annot"><span class="annottext">cannot_inline :: Bool
</span><a href="#local-6989586621681046121"><span class="hs-identifier hs-var hs-var">cannot_inline</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LRegSet
</span><a href="#local-6989586621681046126"><span class="hs-identifier hs-var">skipped</span></a></span><span> </span><span class="annot"><span class="annottext">LRegSet -&gt; CmmExpr -&gt; Bool
</span><a href="GHC.Cmm.Sink.html#regsUsedIn"><span class="hs-operator hs-var">`regsUsedIn`</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681046123"><span class="hs-identifier hs-var">rhs</span></a></span><span> </span><span class="hs-comment">-- Note [dependent assignments]</span><span>
</span><span id="line-453"></span><span>                        </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681046124"><span class="hs-identifier hs-var">l</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg -&gt; LRegSet -&gt; Bool
</span><a href="GHC.Cmm.Sink.html#elemLRegSet"><span class="hs-operator hs-var">`elemLRegSet`</span></a></span><span> </span><span class="annot"><span class="annottext">LRegSet
</span><a href="#local-6989586621681046126"><span class="hs-identifier hs-var">skipped</span></a></span><span>
</span><span id="line-454"></span><span>                        </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; CmmExpr -&gt; CmmNode O x -&gt; Bool
forall (e :: Extensibility) (x :: Extensibility).
DynFlags -&gt; CmmExpr -&gt; CmmNode e x -&gt; Bool
</span><a href="GHC.Cmm.Sink.html#okToInline"><span class="hs-identifier hs-var">okToInline</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046140"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681046123"><span class="hs-identifier hs-var">rhs</span></a></span><span> </span><span class="annot"><span class="annottext">CmmNode O x
</span><a href="#local-6989586621681046127"><span class="hs-identifier hs-var">node</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-455"></span><span>
</span><span id="line-456"></span><span>        </span><span id="local-6989586621681046101"><span class="annot"><span class="annottext">l_usages :: Maybe Int
</span><a href="#local-6989586621681046101"><span class="hs-identifier hs-var hs-var">l_usages</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UniqFM LocalReg Int -&gt; LocalReg -&gt; Maybe Int
forall key elt. Uniquable key =&gt; UniqFM key elt -&gt; key -&gt; Maybe elt
</span><a href="GHC.Types.Unique.FM.html#lookupUFM"><span class="hs-identifier hs-var">lookupUFM</span></a></span><span> </span><span class="annot"><span class="annottext">UniqFM LocalReg Int
</span><a href="#local-6989586621681046128"><span class="hs-identifier hs-var">usages</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681046124"><span class="hs-identifier hs-var">l</span></a></span><span>
</span><span id="line-457"></span><span>        </span><span id="local-6989586621681046099"><span class="annot"><span class="annottext">l_live :: Bool
</span><a href="#local-6989586621681046099"><span class="hs-identifier hs-var hs-var">l_live</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681046124"><span class="hs-identifier hs-var">l</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg -&gt; Set LocalReg -&gt; Bool
forall a. Ord a =&gt; a -&gt; Set a -&gt; Bool
</span><a href="GHC.Cmm.Expr.html#elemRegSet"><span class="hs-operator hs-var">`elemRegSet`</span></a></span><span> </span><span class="annot"><span class="annottext">Set LocalReg
</span><a href="#local-6989586621681046139"><span class="hs-identifier hs-var">live</span></a></span><span>
</span><span id="line-458"></span><span>
</span><span id="line-459"></span><span>        </span><span id="local-6989586621681046117"><span class="annot"><span class="annottext">occurs_once :: Bool
</span><a href="#local-6989586621681046117"><span class="hs-identifier hs-var hs-var">occurs_once</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681046099"><span class="hs-identifier hs-var">l_live</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Maybe Int
</span><a href="#local-6989586621681046101"><span class="hs-identifier hs-var">l_usages</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Int -&gt; Maybe Int -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Maybe Int
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span>
</span><span id="line-460"></span><span>        </span><span id="local-6989586621681046119"><span class="annot"><span class="annottext">occurs_none :: Bool
</span><a href="#local-6989586621681046119"><span class="hs-identifier hs-var hs-var">occurs_none</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681046099"><span class="hs-identifier hs-var">l_live</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Maybe Int
</span><a href="#local-6989586621681046101"><span class="hs-identifier hs-var">l_usages</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Int -&gt; Maybe Int -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Maybe Int
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-461"></span><span>
</span><span id="line-462"></span><span>        </span><span id="local-6989586621681046112"><span class="annot"><span class="annottext">inl_node :: CmmNode O x
</span><a href="#local-6989586621681046112"><span class="hs-identifier hs-var hs-var">inl_node</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CmmNode O x -&gt; CmmNode O x
forall (x :: Extensibility). CmmNode O x -&gt; CmmNode O x
</span><a href="GHC.Cmm.Sink.html#improveConditional"><span class="hs-identifier hs-var">improveConditional</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(CmmExpr -&gt; CmmExpr) -&gt; CmmNode O x -&gt; CmmNode O x
forall (e :: Extensibility) (x :: Extensibility).
(CmmExpr -&gt; CmmExpr) -&gt; CmmNode e x -&gt; CmmNode e x
</span><a href="GHC.Cmm.Node.html#mapExpDeep"><span class="hs-identifier hs-var">mapExpDeep</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr -&gt; CmmExpr
</span><a href="#local-6989586621681046095"><span class="hs-identifier hs-var">inl_exp</span></a></span><span> </span><span class="annot"><span class="annottext">CmmNode O x
</span><a href="#local-6989586621681046127"><span class="hs-identifier hs-var">node</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-463"></span><span>
</span><span id="line-464"></span><span>        </span><span class="annot"><a href="#local-6989586621681046095"><span class="hs-identifier hs-type">inl_exp</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span>
</span><span id="line-465"></span><span>        </span><span class="hs-comment">-- inl_exp is where the inlining actually takes place!</span><span>
</span><span id="line-466"></span><span>        </span><span id="local-6989586621681046095"><span class="annot"><span class="annottext">inl_exp :: CmmExpr -&gt; CmmExpr
</span><a href="#local-6989586621681046095"><span class="hs-identifier hs-var hs-var">inl_exp</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmReg"><span class="hs-identifier hs-type">CmmReg</span></a></span><span>    </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmLocal"><span class="hs-identifier hs-type">CmmLocal</span></a></span><span> </span><span id="local-6989586621681046094"><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681046094"><span class="hs-identifier hs-var">l'</span></a></span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>     </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681046124"><span class="hs-identifier hs-var">l</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg -&gt; LocalReg -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681046094"><span class="hs-identifier hs-var">l'</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681046123"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-467"></span><span>        </span><span class="annot"><a href="#local-6989586621681046095"><span class="hs-identifier hs-var">inl_exp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmRegOff"><span class="hs-identifier hs-type">CmmRegOff</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmLocal"><span class="hs-identifier hs-type">CmmLocal</span></a></span><span> </span><span id="local-6989586621681046092"><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681046092"><span class="hs-identifier hs-var">l'</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681046091"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681046091"><span class="hs-identifier hs-var">off</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681046124"><span class="hs-identifier hs-var">l</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg -&gt; LocalReg -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681046092"><span class="hs-identifier hs-var">l'</span></a></span><span>
</span><span id="line-468"></span><span>                    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; CmmExpr -&gt; Int -&gt; CmmExpr
</span><a href="GHC.Cmm.Utils.html#cmmOffset"><span class="hs-identifier hs-var">cmmOffset</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681046114"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681046123"><span class="hs-identifier hs-var">rhs</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681046091"><span class="hs-identifier hs-var">off</span></a></span><span>
</span><span id="line-469"></span><span>                    </span><span class="hs-comment">-- re-constant fold after inlining</span><span>
</span><span id="line-470"></span><span>        </span><span class="annot"><a href="#local-6989586621681046095"><span class="hs-identifier hs-var">inl_exp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmMachOp"><span class="hs-identifier hs-type">CmmMachOp</span></a></span><span> </span><span id="local-6989586621681046088"><span class="annot"><span class="annottext">MachOp
</span><a href="#local-6989586621681046088"><span class="hs-identifier hs-var">op</span></a></span></span><span> </span><span id="local-6989586621681046087"><span class="annot"><span class="annottext">[CmmExpr]
</span><a href="#local-6989586621681046087"><span class="hs-identifier hs-var">args</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; MachOp -&gt; [CmmExpr] -&gt; CmmExpr
</span><a href="GHC.Cmm.Opt.html#cmmMachOpFold"><span class="hs-identifier hs-var">cmmMachOpFold</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681046114"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">MachOp
</span><a href="#local-6989586621681046088"><span class="hs-identifier hs-var">op</span></a></span><span> </span><span class="annot"><span class="annottext">[CmmExpr]
</span><a href="#local-6989586621681046087"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-471"></span><span>        </span><span class="annot"><a href="#local-6989586621681046095"><span class="hs-identifier hs-var">inl_exp</span></a></span><span> </span><span id="local-6989586621681046085"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681046085"><span class="hs-identifier hs-var">other</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681046085"><span class="hs-identifier hs-var">other</span></a></span><span>
</span><span id="line-472"></span><span>
</span><span id="line-473"></span><span>
</span><span id="line-474"></span><span class="hs-comment">{- Note [improveConditional]

cmmMachOpFold tries to simplify conditionals to turn things like
  (a == b) != 1
into
  (a != b)
but there's one case it can't handle: when the comparison is over
floating-point values, we can't invert it, because floating-point
comparisons aren't invertible (because of NaNs).

But we *can* optimise this conditional by swapping the true and false
branches. Given
  CmmCondBranch ((a &gt;## b) != 1) t f
we can turn it into
  CmmCondBranch (a &gt;## b) f t

So here we catch conditionals that weren't optimised by cmmMachOpFold,
and apply above transformation to eliminate the comparison against 1.

It's tempting to just turn every != into == and then let cmmMachOpFold
do its thing, but that risks changing a nice fall-through conditional
into one that requires two jumps. (see swapcond_last in
GHC.Cmm.ContFlowOpt), so instead we carefully look for just the cases where
we can eliminate a comparison.
-}</span><span>
</span><span id="line-499"></span><span id="local-6989586621681046457"><span class="annot"><a href="GHC.Cmm.Sink.html#improveConditional"><span class="hs-identifier hs-type">improveConditional</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Node.html#CmmNode"><span class="hs-identifier hs-type">CmmNode</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Block.html#O"><span class="hs-identifier hs-type">O</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681046457"><span class="hs-identifier hs-type">x</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Node.html#CmmNode"><span class="hs-identifier hs-type">CmmNode</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Block.html#O"><span class="hs-identifier hs-type">O</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681046457"><span class="hs-identifier hs-type">x</span></a></span></span><span>
</span><span id="line-500"></span><span id="improveConditional"><span class="annot"><span class="annottext">improveConditional :: forall (x :: Extensibility). CmmNode O x -&gt; CmmNode O x
</span><a href="GHC.Cmm.Sink.html#improveConditional"><span class="hs-identifier hs-var hs-var">improveConditional</span></a></span></span><span>
</span><span id="line-501"></span><span>  </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Node.html#CmmCondBranch"><span class="hs-identifier hs-type">CmmCondBranch</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmMachOp"><span class="hs-identifier hs-type">CmmMachOp</span></a></span><span> </span><span id="local-6989586621681046075"><span class="annot"><span class="annottext">MachOp
</span><a href="#local-6989586621681046075"><span class="hs-identifier hs-var">mop</span></a></span></span><span> </span><span class="hs-special">[</span><span id="local-6989586621681046074"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681046074"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmLit"><span class="hs-identifier hs-type">CmmLit</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmInt"><span class="hs-identifier hs-type">CmmInt</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><span class="hs-number">1</span></span><span> </span><span class="annot"><span class="annottext">Width
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span id="local-6989586621681046072"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681046072"><span class="hs-identifier hs-var">t</span></a></span></span><span> </span><span id="local-6989586621681046071"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681046071"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621681046070"><span class="annot"><span class="annottext">Maybe Bool
</span><a href="#local-6989586621681046070"><span class="hs-identifier hs-var">l</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-502"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">MachOp -&gt; Bool
</span><a href="#local-6989586621681046069"><span class="hs-identifier hs-var">neLike</span></a></span><span> </span><span class="annot"><span class="annottext">MachOp
</span><a href="#local-6989586621681046075"><span class="hs-identifier hs-var">mop</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CmmExpr -&gt; Bool
</span><a href="GHC.Cmm.Utils.html#isComparisonExpr"><span class="hs-identifier hs-var">isComparisonExpr</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681046074"><span class="hs-identifier hs-var">x</span></a></span><span>
</span><span id="line-503"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CmmExpr -&gt; BlockId -&gt; BlockId -&gt; Maybe Bool -&gt; CmmNode O C
</span><a href="GHC.Cmm.Node.html#CmmCondBranch"><span class="hs-identifier hs-var">CmmCondBranch</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681046074"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681046071"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681046072"><span class="hs-identifier hs-var">t</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Bool -&gt; Bool) -&gt; Maybe Bool -&gt; Maybe Bool
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Maybe Bool
</span><a href="#local-6989586621681046070"><span class="hs-identifier hs-var">l</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-504"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-505"></span><span>    </span><span id="local-6989586621681046069"><span class="annot"><span class="annottext">neLike :: MachOp -&gt; Bool
</span><a href="#local-6989586621681046069"><span class="hs-identifier hs-var hs-var">neLike</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.MachOp.html#MO_Ne"><span class="hs-identifier hs-type">MO_Ne</span></a></span><span> </span><span class="annot"><span class="annottext">Width
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-506"></span><span>    </span><span class="annot"><a href="#local-6989586621681046069"><span class="hs-identifier hs-var">neLike</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.MachOp.html#MO_U_Lt"><span class="hs-identifier hs-type">MO_U_Lt</span></a></span><span> </span><span class="annot"><span class="annottext">Width
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>   </span><span class="hs-comment">-- (x&lt;y) &lt; 1 behaves like (x&lt;y) != 1</span><span>
</span><span id="line-507"></span><span>    </span><span class="annot"><a href="#local-6989586621681046069"><span class="hs-identifier hs-var">neLike</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.MachOp.html#MO_S_Lt"><span class="hs-identifier hs-type">MO_S_Lt</span></a></span><span> </span><span class="annot"><span class="annottext">Width
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>   </span><span class="hs-comment">-- (x&lt;y) &lt; 1 behaves like (x&lt;y) != 1</span><span>
</span><span id="line-508"></span><span>    </span><span class="annot"><a href="#local-6989586621681046069"><span class="hs-identifier hs-var">neLike</span></a></span><span> </span><span class="annot"><span class="annottext">MachOp
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-509"></span><span class="annot"><a href="GHC.Cmm.Sink.html#improveConditional"><span class="hs-identifier hs-var">improveConditional</span></a></span><span> </span><span id="local-6989586621681046064"><span class="annot"><span class="annottext">CmmNode O x
</span><a href="#local-6989586621681046064"><span class="hs-identifier hs-var">other</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CmmNode O x
</span><a href="#local-6989586621681046064"><span class="hs-identifier hs-var">other</span></a></span><span>
</span><span id="line-510"></span><span>
</span><span id="line-511"></span><span class="hs-comment">-- Note [dependent assignments]</span><span>
</span><span id="line-512"></span><span class="hs-comment">-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span><span>
</span><span id="line-513"></span><span class="hs-comment">--</span><span>
</span><span id="line-514"></span><span class="hs-comment">-- If our assignment list looks like</span><span>
</span><span id="line-515"></span><span class="hs-comment">--</span><span>
</span><span id="line-516"></span><span class="hs-comment">--    [ y = e,  x = ... y ... ]</span><span>
</span><span id="line-517"></span><span class="hs-comment">--</span><span>
</span><span id="line-518"></span><span class="hs-comment">-- We cannot inline x.  Remember this list is really in reverse order,</span><span>
</span><span id="line-519"></span><span class="hs-comment">-- so it means  x = ... y ...; y = e</span><span>
</span><span id="line-520"></span><span class="hs-comment">--</span><span>
</span><span id="line-521"></span><span class="hs-comment">-- Hence if we inline x, the outer assignment to y will capture the</span><span>
</span><span id="line-522"></span><span class="hs-comment">-- reference in x's right hand side.</span><span>
</span><span id="line-523"></span><span class="hs-comment">--</span><span>
</span><span id="line-524"></span><span class="hs-comment">-- In this case we should rename the y in x's right-hand side,</span><span>
</span><span id="line-525"></span><span class="hs-comment">-- i.e. change the list to [ y = e, x = ... y1 ..., y1 = y ]</span><span>
</span><span id="line-526"></span><span class="hs-comment">-- Now we can go ahead and inline x.</span><span>
</span><span id="line-527"></span><span class="hs-comment">--</span><span>
</span><span id="line-528"></span><span class="hs-comment">-- For now we do nothing, because this would require putting</span><span>
</span><span id="line-529"></span><span class="hs-comment">-- everything inside UniqSM.</span><span>
</span><span id="line-530"></span><span class="hs-comment">--</span><span>
</span><span id="line-531"></span><span class="hs-comment">-- One more variant of this (#7366):</span><span>
</span><span id="line-532"></span><span class="hs-comment">--</span><span>
</span><span id="line-533"></span><span class="hs-comment">--   [ y = e, y = z ]</span><span>
</span><span id="line-534"></span><span class="hs-comment">--</span><span>
</span><span id="line-535"></span><span class="hs-comment">-- If we don't want to inline y = e, because y is used many times, we</span><span>
</span><span id="line-536"></span><span class="hs-comment">-- might still be tempted to inline y = z (because we always inline</span><span>
</span><span id="line-537"></span><span class="hs-comment">-- trivial rhs's).  But of course we can't, because y is equal to e,</span><span>
</span><span id="line-538"></span><span class="hs-comment">-- not z.</span><span>
</span><span id="line-539"></span><span>
</span><span id="line-540"></span><span class="hs-comment">-- Note [discard during inlining]</span><span>
</span><span id="line-541"></span><span class="hs-comment">-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span><span>
</span><span id="line-542"></span><span class="hs-comment">-- Opportunities to discard assignments sometimes appear after we've</span><span>
</span><span id="line-543"></span><span class="hs-comment">-- done some inlining.  Here's an example:</span><span>
</span><span id="line-544"></span><span class="hs-comment">--</span><span>
</span><span id="line-545"></span><span class="hs-comment">--      x = R1;</span><span>
</span><span id="line-546"></span><span class="hs-comment">--      y = P64[x + 7];</span><span>
</span><span id="line-547"></span><span class="hs-comment">--      z = P64[x + 15];</span><span>
</span><span id="line-548"></span><span class="hs-comment">--      /* z is dead */</span><span>
</span><span id="line-549"></span><span class="hs-comment">--      R1 = y &amp; (-8);</span><span>
</span><span id="line-550"></span><span class="hs-comment">--</span><span>
</span><span id="line-551"></span><span class="hs-comment">-- The x assignment is trivial, so we inline it in the RHS of y, and</span><span>
</span><span id="line-552"></span><span class="hs-comment">-- keep both x and y.  z gets dropped because it is dead, then we</span><span>
</span><span id="line-553"></span><span class="hs-comment">-- inline y, and we have a dead assignment to x.  If we don't notice</span><span>
</span><span id="line-554"></span><span class="hs-comment">-- that x is dead in tryToInline, we end up retaining it.</span><span>
</span><span id="line-555"></span><span>
</span><span id="line-556"></span><span class="annot"><a href="GHC.Cmm.Sink.html#addUsage"><span class="hs-identifier hs-type">addUsage</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Unique.FM.html#UniqFM"><span class="hs-identifier hs-type">UniqFM</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#LocalReg"><span class="hs-identifier hs-type">LocalReg</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#LocalReg"><span class="hs-identifier hs-type">LocalReg</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Unique.FM.html#UniqFM"><span class="hs-identifier hs-type">UniqFM</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#LocalReg"><span class="hs-identifier hs-type">LocalReg</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>
</span><span id="line-557"></span><span id="addUsage"><span class="annot"><span class="annottext">addUsage :: UniqFM LocalReg Int -&gt; LocalReg -&gt; UniqFM LocalReg Int
</span><a href="GHC.Cmm.Sink.html#addUsage"><span class="hs-identifier hs-var hs-var">addUsage</span></a></span></span><span> </span><span id="local-6989586621681046063"><span class="annot"><span class="annottext">UniqFM LocalReg Int
</span><a href="#local-6989586621681046063"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621681046062"><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681046062"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Int -&gt; Int -&gt; Int)
-&gt; UniqFM LocalReg Int -&gt; LocalReg -&gt; Int -&gt; UniqFM LocalReg Int
forall key elt.
Uniquable key =&gt;
(elt -&gt; elt -&gt; elt)
-&gt; UniqFM key elt -&gt; key -&gt; elt -&gt; UniqFM key elt
</span><a href="GHC.Types.Unique.FM.html#addToUFM_C"><span class="hs-identifier hs-var">addToUFM_C</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">(+)</span></a></span><span> </span><span class="annot"><span class="annottext">UniqFM LocalReg Int
</span><a href="#local-6989586621681046063"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681046062"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span>
</span><span id="line-558"></span><span>
</span><span id="line-559"></span><span class="annot"><a href="GHC.Cmm.Sink.html#regsUsedIn"><span class="hs-identifier hs-type">regsUsedIn</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Sink.html#LRegSet"><span class="hs-identifier hs-type">LRegSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-560"></span><span id="regsUsedIn"><span class="annot"><span class="annottext">regsUsedIn :: LRegSet -&gt; CmmExpr -&gt; Bool
</span><a href="GHC.Cmm.Sink.html#regsUsedIn"><span class="hs-identifier hs-var hs-var">regsUsedIn</span></a></span></span><span> </span><span id="local-6989586621681046060"><span class="annot"><span class="annottext">LRegSet
</span><a href="#local-6989586621681046060"><span class="hs-identifier hs-var">ls</span></a></span></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">LRegSet -&gt; Bool
</span><a href="GHC.Cmm.Sink.html#nullLRegSet"><span class="hs-identifier hs-var">nullLRegSet</span></a></span><span> </span><span class="annot"><span class="annottext">LRegSet
</span><a href="#local-6989586621681046060"><span class="hs-identifier hs-var">ls</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-561"></span><span class="annot"><a href="GHC.Cmm.Sink.html#regsUsedIn"><span class="hs-identifier hs-var">regsUsedIn</span></a></span><span> </span><span id="local-6989586621681046059"><span class="annot"><span class="annottext">LRegSet
</span><a href="#local-6989586621681046059"><span class="hs-identifier hs-var">ls</span></a></span></span><span> </span><span id="local-6989586621681046058"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681046058"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CmmExpr -&gt; Bool -&gt; Bool) -&gt; CmmExpr -&gt; Bool -&gt; Bool
forall z. (CmmExpr -&gt; z -&gt; z) -&gt; CmmExpr -&gt; z -&gt; z
</span><a href="GHC.Cmm.Node.html#wrapRecExpf"><span class="hs-identifier hs-var">wrapRecExpf</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr -&gt; Bool -&gt; Bool
</span><a href="#local-6989586621681046056"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681046058"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-562"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621681046056"><span class="annot"><span class="annottext">f :: CmmExpr -&gt; Bool -&gt; Bool
</span><a href="#local-6989586621681046056"><span class="hs-identifier hs-var hs-var">f</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmReg"><span class="hs-identifier hs-type">CmmReg</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmLocal"><span class="hs-identifier hs-type">CmmLocal</span></a></span><span> </span><span id="local-6989586621681046055"><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681046055"><span class="hs-identifier hs-var">l</span></a></span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>      </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681046055"><span class="hs-identifier hs-var">l</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg -&gt; LRegSet -&gt; Bool
</span><a href="GHC.Cmm.Sink.html#elemLRegSet"><span class="hs-operator hs-var">`elemLRegSet`</span></a></span><span> </span><span class="annot"><span class="annottext">LRegSet
</span><a href="#local-6989586621681046059"><span class="hs-identifier hs-var">ls</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-563"></span><span>        </span><span class="annot"><a href="#local-6989586621681046056"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmRegOff"><span class="hs-identifier hs-type">CmmRegOff</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmLocal"><span class="hs-identifier hs-type">CmmLocal</span></a></span><span> </span><span id="local-6989586621681046054"><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681046054"><span class="hs-identifier hs-var">l</span></a></span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681046054"><span class="hs-identifier hs-var">l</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg -&gt; LRegSet -&gt; Bool
</span><a href="GHC.Cmm.Sink.html#elemLRegSet"><span class="hs-operator hs-var">`elemLRegSet`</span></a></span><span> </span><span class="annot"><span class="annottext">LRegSet
</span><a href="#local-6989586621681046059"><span class="hs-identifier hs-var">ls</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-564"></span><span>        </span><span class="annot"><a href="#local-6989586621681046056"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681046053"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681046053"><span class="hs-identifier hs-var">z</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681046053"><span class="hs-identifier hs-var">z</span></a></span><span>
</span><span id="line-565"></span><span>
</span><span id="line-566"></span><span class="hs-comment">-- we don't inline into CmmUnsafeForeignCall if the expression refers</span><span>
</span><span id="line-567"></span><span class="hs-comment">-- to global registers.  This is a HACK to avoid global registers</span><span>
</span><span id="line-568"></span><span class="hs-comment">-- clashing with C argument-passing registers, really the back-end</span><span>
</span><span id="line-569"></span><span class="hs-comment">-- ought to be able to handle it properly, but currently neither PprC</span><span>
</span><span id="line-570"></span><span class="hs-comment">-- nor the NCG can do it.  See Note [Register parameter passing]</span><span>
</span><span id="line-571"></span><span class="hs-comment">-- See also GHC.StgToCmm.Foreign.load_args_into_temps.</span><span>
</span><span id="line-572"></span><span id="local-6989586621681046460"><span id="local-6989586621681046461"><span class="annot"><a href="GHC.Cmm.Sink.html#okToInline"><span class="hs-identifier hs-type">okToInline</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Node.html#CmmNode"><span class="hs-identifier hs-type">CmmNode</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681046461"><span class="hs-identifier hs-type">e</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681046460"><span class="hs-identifier hs-type">x</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span></span></span><span>
</span><span id="line-573"></span><span id="okToInline"><span class="annot"><span class="annottext">okToInline :: forall (e :: Extensibility) (x :: Extensibility).
DynFlags -&gt; CmmExpr -&gt; CmmNode e x -&gt; Bool
</span><a href="GHC.Cmm.Sink.html#okToInline"><span class="hs-identifier hs-var hs-var">okToInline</span></a></span></span><span> </span><span id="local-6989586621681046052"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046052"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681046051"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681046051"><span class="hs-identifier hs-var">expr</span></a></span></span><span> </span><span id="local-6989586621681046050"><span class="annot"><span class="annottext">node :: CmmNode e x
</span><a href="#local-6989586621681046050"><span class="hs-identifier hs-var">node</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Node.html#CmmUnsafeForeignCall"><span class="hs-identifier hs-type">CmmUnsafeForeignCall</span></a></span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-574"></span><span>    </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; CmmExpr -&gt; CmmNode e x -&gt; Bool
forall (e :: Extensibility) (x :: Extensibility).
DynFlags -&gt; CmmExpr -&gt; CmmNode e x -&gt; Bool
</span><a href="GHC.Cmm.Sink.html#globalRegistersConflict"><span class="hs-identifier hs-var">globalRegistersConflict</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046052"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681046051"><span class="hs-identifier hs-var">expr</span></a></span><span> </span><span class="annot"><span class="annottext">CmmNode e x
</span><a href="#local-6989586621681046050"><span class="hs-identifier hs-var">node</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-575"></span><span class="annot"><a href="GHC.Cmm.Sink.html#okToInline"><span class="hs-identifier hs-var">okToInline</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">CmmNode e x
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-576"></span><span>
</span><span id="line-577"></span><span class="hs-comment">-- -----------------------------------------------------------------------------</span><span>
</span><span id="line-578"></span><span>
</span><span id="line-579"></span><span class="hs-comment">-- | @conflicts (r,e) node@ is @False@ if and only if the assignment</span><span>
</span><span id="line-580"></span><span class="hs-comment">-- @r = e@ can be safely commuted past statement @node@.</span><span>
</span><span id="line-581"></span><span id="local-6989586621681046514"><span class="annot"><a href="GHC.Cmm.Sink.html#conflicts"><span class="hs-identifier hs-type">conflicts</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Sink.html#Assignment"><span class="hs-identifier hs-type">Assignment</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Node.html#CmmNode"><span class="hs-identifier hs-type">CmmNode</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Block.html#O"><span class="hs-identifier hs-type">O</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681046514"><span class="hs-identifier hs-type">x</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span></span><span>
</span><span id="line-582"></span><span id="conflicts"><span class="annot"><span class="annottext">conflicts :: forall (x :: Extensibility).
DynFlags -&gt; Assignment -&gt; CmmNode O x -&gt; Bool
</span><a href="GHC.Cmm.Sink.html#conflicts"><span class="hs-identifier hs-var hs-var">conflicts</span></a></span></span><span> </span><span id="local-6989586621681046043"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046043"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681046042"><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681046042"><span class="hs-identifier hs-var">r</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681046041"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681046041"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681046040"><span class="annot"><span class="annottext">AbsMem
</span><a href="#local-6989586621681046040"><span class="hs-identifier hs-var">addr</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681046039"><span class="annot"><span class="annottext">CmmNode O x
</span><a href="#local-6989586621681046039"><span class="hs-identifier hs-var">node</span></a></span></span><span>
</span><span id="line-583"></span><span>
</span><span id="line-584"></span><span>  </span><span class="hs-comment">-- (1) node defines registers used by rhs of assignment. This catches</span><span>
</span><span id="line-585"></span><span>  </span><span class="hs-comment">-- assignments and all three kinds of calls. See Note [Sinking and calls]</span><span>
</span><span id="line-586"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; CmmExpr -&gt; CmmNode O x -&gt; Bool
forall (e :: Extensibility) (x :: Extensibility).
DynFlags -&gt; CmmExpr -&gt; CmmNode e x -&gt; Bool
</span><a href="GHC.Cmm.Sink.html#globalRegistersConflict"><span class="hs-identifier hs-var">globalRegistersConflict</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046043"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681046041"><span class="hs-identifier hs-var">rhs</span></a></span><span> </span><span class="annot"><span class="annottext">CmmNode O x
</span><a href="#local-6989586621681046039"><span class="hs-identifier hs-var">node</span></a></span><span>                       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-587"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; CmmExpr -&gt; CmmNode O x -&gt; Bool
forall (e :: Extensibility) (x :: Extensibility).
DynFlags -&gt; CmmExpr -&gt; CmmNode e x -&gt; Bool
</span><a href="GHC.Cmm.Sink.html#localRegistersConflict"><span class="hs-identifier hs-var">localRegistersConflict</span></a></span><span>  </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046043"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681046041"><span class="hs-identifier hs-var">rhs</span></a></span><span> </span><span class="annot"><span class="annottext">CmmNode O x
</span><a href="#local-6989586621681046039"><span class="hs-identifier hs-var">node</span></a></span><span>                       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-588"></span><span>
</span><span id="line-589"></span><span>  </span><span class="hs-comment">-- (2) node uses register defined by assignment</span><span>
</span><span id="line-590"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">DynFlags
-&gt; (Bool -&gt; LocalReg -&gt; Bool) -&gt; Bool -&gt; CmmNode O x -&gt; Bool
forall r a b.
UserOfRegs r a =&gt;
DynFlags -&gt; (b -&gt; r -&gt; b) -&gt; b -&gt; a -&gt; b
</span><a href="GHC.Cmm.Expr.html#foldRegsUsed"><span class="hs-identifier hs-var">foldRegsUsed</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046043"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681046037"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681046037"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span id="local-6989586621681046036"><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681046036"><span class="hs-identifier hs-var">r'</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681046042"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg -&gt; LocalReg -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681046036"><span class="hs-identifier hs-var">r'</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681046037"><span class="hs-identifier hs-var">b</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">CmmNode O x
</span><a href="#local-6989586621681046039"><span class="hs-identifier hs-var">node</span></a></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-591"></span><span>
</span><span id="line-592"></span><span>  </span><span class="hs-comment">-- (3) a store to an address conflicts with a read of the same memory</span><span>
</span><span id="line-593"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Cmm.Node.html#CmmStore"><span class="hs-identifier hs-type">CmmStore</span></a></span><span> </span><span id="local-6989586621681046032"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681046032"><span class="hs-identifier hs-var">addr'</span></a></span></span><span> </span><span id="local-6989586621681046031"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681046031"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CmmNode O x
</span><a href="#local-6989586621681046039"><span class="hs-identifier hs-var">node</span></a></span><span>
</span><span id="line-594"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">AbsMem -&gt; AbsMem -&gt; Bool
</span><a href="GHC.Cmm.Sink.html#memConflicts"><span class="hs-identifier hs-var">memConflicts</span></a></span><span> </span><span class="annot"><span class="annottext">AbsMem
</span><a href="#local-6989586621681046040"><span class="hs-identifier hs-var">addr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; CmmExpr -&gt; Width -&gt; AbsMem
</span><a href="GHC.Cmm.Sink.html#loadAddr"><span class="hs-identifier hs-var">loadAddr</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681046028"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681046032"><span class="hs-identifier hs-var">addr'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; CmmExpr -&gt; Width
</span><a href="GHC.Cmm.Expr.html#cmmExprWidth"><span class="hs-identifier hs-var">cmmExprWidth</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681046028"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681046031"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-595"></span><span>
</span><span id="line-596"></span><span>  </span><span class="hs-comment">-- (4) an assignment to Hp/Sp conflicts with a heap/stack read respectively</span><span>
</span><span id="line-597"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">AbsMem
</span><a href="GHC.Cmm.Sink.html#HeapMem"><span class="hs-identifier hs-var">HeapMem</span></a></span><span>    </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">AbsMem
</span><a href="#local-6989586621681046040"><span class="hs-identifier hs-var">addr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Cmm.Node.html#CmmAssign"><span class="hs-identifier hs-type">CmmAssign</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmGlobal"><span class="hs-identifier hs-type">CmmGlobal</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalReg
</span><a href="GHC.Cmm.Expr.html#Hp"><span class="hs-identifier hs-var">Hp</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CmmNode O x
</span><a href="#local-6989586621681046039"><span class="hs-identifier hs-var">node</span></a></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-598"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">AbsMem
</span><a href="GHC.Cmm.Sink.html#StackMem"><span class="hs-identifier hs-var">StackMem</span></a></span><span>   </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">AbsMem
</span><a href="#local-6989586621681046040"><span class="hs-identifier hs-var">addr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Cmm.Node.html#CmmAssign"><span class="hs-identifier hs-type">CmmAssign</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmGlobal"><span class="hs-identifier hs-type">CmmGlobal</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalReg
</span><a href="GHC.Cmm.Expr.html#Sp"><span class="hs-identifier hs-var">Sp</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CmmNode O x
</span><a href="#local-6989586621681046039"><span class="hs-identifier hs-var">node</span></a></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-599"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Cmm.Sink.html#SpMem"><span class="hs-identifier hs-type">SpMem</span></a></span><span class="hs-special">{</span><span class="hs-special">}</span><span>    </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">AbsMem
</span><a href="#local-6989586621681046040"><span class="hs-identifier hs-var">addr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Cmm.Node.html#CmmAssign"><span class="hs-identifier hs-type">CmmAssign</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmGlobal"><span class="hs-identifier hs-type">CmmGlobal</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalReg
</span><a href="GHC.Cmm.Expr.html#Sp"><span class="hs-identifier hs-var">Sp</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CmmNode O x
</span><a href="#local-6989586621681046039"><span class="hs-identifier hs-var">node</span></a></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-600"></span><span>
</span><span id="line-601"></span><span>  </span><span class="hs-comment">-- (5) foreign calls clobber heap: see Note [Foreign calls clobber heap]</span><span>
</span><span id="line-602"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Cmm.Node.html#CmmUnsafeForeignCall"><span class="hs-identifier hs-type">CmmUnsafeForeignCall</span></a></span><span class="hs-special">{</span><span class="hs-special">}</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CmmNode O x
</span><a href="#local-6989586621681046039"><span class="hs-identifier hs-var">node</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">AbsMem -&gt; AbsMem -&gt; Bool
</span><a href="GHC.Cmm.Sink.html#memConflicts"><span class="hs-identifier hs-var">memConflicts</span></a></span><span> </span><span class="annot"><span class="annottext">AbsMem
</span><a href="#local-6989586621681046040"><span class="hs-identifier hs-var">addr</span></a></span><span> </span><span class="annot"><span class="annottext">AbsMem
</span><a href="GHC.Cmm.Sink.html#AnyMem"><span class="hs-identifier hs-var">AnyMem</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-603"></span><span>
</span><span id="line-604"></span><span>  </span><span class="hs-comment">-- (6) native calls clobber any memory</span><span>
</span><span id="line-605"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Cmm.Node.html#CmmCall"><span class="hs-identifier hs-type">CmmCall</span></a></span><span class="hs-special">{</span><span class="hs-special">}</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CmmNode O x
</span><a href="#local-6989586621681046039"><span class="hs-identifier hs-var">node</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">AbsMem -&gt; AbsMem -&gt; Bool
</span><a href="GHC.Cmm.Sink.html#memConflicts"><span class="hs-identifier hs-var">memConflicts</span></a></span><span> </span><span class="annot"><span class="annottext">AbsMem
</span><a href="#local-6989586621681046040"><span class="hs-identifier hs-var">addr</span></a></span><span> </span><span class="annot"><span class="annottext">AbsMem
</span><a href="GHC.Cmm.Sink.html#AnyMem"><span class="hs-identifier hs-var">AnyMem</span></a></span><span>                   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-606"></span><span>
</span><span id="line-607"></span><span>  </span><span class="hs-comment">-- (7) otherwise, no conflict</span><span>
</span><span id="line-608"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-609"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-610"></span><span>    </span><span id="local-6989586621681046028"><span class="annot"><span class="annottext">platform :: Platform
</span><a href="#local-6989586621681046028"><span class="hs-identifier hs-var hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Platform
</span><a href="GHC.Driver.Session.html#targetPlatform"><span class="hs-identifier hs-var hs-var">targetPlatform</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046043"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-611"></span><span>
</span><span id="line-612"></span><span class="hs-comment">-- Returns True if node defines any global registers that are used in the</span><span>
</span><span id="line-613"></span><span class="hs-comment">-- Cmm expression</span><span>
</span><span id="line-614"></span><span id="local-6989586621681046008"><span id="local-6989586621681046009"><span class="annot"><a href="GHC.Cmm.Sink.html#globalRegistersConflict"><span class="hs-identifier hs-type">globalRegistersConflict</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Node.html#CmmNode"><span class="hs-identifier hs-type">CmmNode</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681046009"><span class="hs-identifier hs-type">e</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681046008"><span class="hs-identifier hs-type">x</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span></span></span><span>
</span><span id="line-615"></span><span id="globalRegistersConflict"><span class="annot"><span class="annottext">globalRegistersConflict :: forall (e :: Extensibility) (x :: Extensibility).
DynFlags -&gt; CmmExpr -&gt; CmmNode e x -&gt; Bool
</span><a href="GHC.Cmm.Sink.html#globalRegistersConflict"><span class="hs-identifier hs-var hs-var">globalRegistersConflict</span></a></span></span><span> </span><span id="local-6989586621681046005"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046005"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681046004"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681046004"><span class="hs-identifier hs-var">expr</span></a></span></span><span> </span><span id="local-6989586621681046003"><span class="annot"><span class="annottext">CmmNode e x
</span><a href="#local-6989586621681046003"><span class="hs-identifier hs-var">node</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-616"></span><span>    </span><span class="annot"><span class="annottext">DynFlags
-&gt; (Bool -&gt; GlobalReg -&gt; Bool) -&gt; Bool -&gt; CmmNode e x -&gt; Bool
forall r a b.
DefinerOfRegs r a =&gt;
DynFlags -&gt; (b -&gt; r -&gt; b) -&gt; b -&gt; a -&gt; b
</span><a href="GHC.Cmm.Expr.html#foldRegsDefd"><span class="hs-identifier hs-var">foldRegsDefd</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046005"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681046001"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681046001"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span id="local-6989586621681046000"><span class="annot"><span class="annottext">GlobalReg
</span><a href="#local-6989586621681046000"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681046001"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Platform -&gt; CmmReg -&gt; CmmExpr -&gt; Bool
</span><a href="GHC.Cmm.Utils.html#regUsedIn"><span class="hs-identifier hs-var">regUsedIn</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; Platform
</span><a href="GHC.Driver.Session.html#targetPlatform"><span class="hs-identifier hs-var hs-var">targetPlatform</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681046005"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GlobalReg -&gt; CmmReg
</span><a href="GHC.Cmm.Expr.html#CmmGlobal"><span class="hs-identifier hs-var">CmmGlobal</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalReg
</span><a href="#local-6989586621681046000"><span class="hs-identifier hs-var">r</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681046004"><span class="hs-identifier hs-var">expr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-617"></span><span>                 </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">CmmNode e x
</span><a href="#local-6989586621681046003"><span class="hs-identifier hs-var">node</span></a></span><span>
</span><span id="line-618"></span><span>
</span><span id="line-619"></span><span class="hs-comment">-- Returns True if node defines any local registers that are used in the</span><span>
</span><span id="line-620"></span><span class="hs-comment">-- Cmm expression</span><span>
</span><span id="line-621"></span><span id="local-6989586621681045997"><span id="local-6989586621681045998"><span class="annot"><a href="GHC.Cmm.Sink.html#localRegistersConflict"><span class="hs-identifier hs-type">localRegistersConflict</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Node.html#CmmNode"><span class="hs-identifier hs-type">CmmNode</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681045998"><span class="hs-identifier hs-type">e</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681045997"><span class="hs-identifier hs-type">x</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span></span></span><span>
</span><span id="line-622"></span><span id="localRegistersConflict"><span class="annot"><span class="annottext">localRegistersConflict :: forall (e :: Extensibility) (x :: Extensibility).
DynFlags -&gt; CmmExpr -&gt; CmmNode e x -&gt; Bool
</span><a href="GHC.Cmm.Sink.html#localRegistersConflict"><span class="hs-identifier hs-var hs-var">localRegistersConflict</span></a></span></span><span> </span><span id="local-6989586621681045995"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681045995"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681045994"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681045994"><span class="hs-identifier hs-var">expr</span></a></span></span><span> </span><span id="local-6989586621681045993"><span class="annot"><span class="annottext">CmmNode e x
</span><a href="#local-6989586621681045993"><span class="hs-identifier hs-var">node</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-623"></span><span>    </span><span class="annot"><span class="annottext">DynFlags
-&gt; (Bool -&gt; LocalReg -&gt; Bool) -&gt; Bool -&gt; CmmNode e x -&gt; Bool
forall r a b.
DefinerOfRegs r a =&gt;
DynFlags -&gt; (b -&gt; r -&gt; b) -&gt; b -&gt; a -&gt; b
</span><a href="GHC.Cmm.Expr.html#foldRegsDefd"><span class="hs-identifier hs-var">foldRegsDefd</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681045995"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681045992"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681045992"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span id="local-6989586621681045991"><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681045991"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681045992"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Platform -&gt; CmmReg -&gt; CmmExpr -&gt; Bool
</span><a href="GHC.Cmm.Utils.html#regUsedIn"><span class="hs-identifier hs-var">regUsedIn</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; Platform
</span><a href="GHC.Driver.Session.html#targetPlatform"><span class="hs-identifier hs-var hs-var">targetPlatform</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681045995"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LocalReg -&gt; CmmReg
</span><a href="GHC.Cmm.Expr.html#CmmLocal"><span class="hs-identifier hs-var">CmmLocal</span></a></span><span>  </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681045991"><span class="hs-identifier hs-var">r</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681045994"><span class="hs-identifier hs-var">expr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-624"></span><span>                 </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">CmmNode e x
</span><a href="#local-6989586621681045993"><span class="hs-identifier hs-var">node</span></a></span><span>
</span><span id="line-625"></span><span>
</span><span id="line-626"></span><span class="hs-comment">-- Note [Sinking and calls]</span><span>
</span><span id="line-627"></span><span class="hs-comment">-- ~~~~~~~~~~~~~~~~~~~~~~~~</span><span>
</span><span id="line-628"></span><span class="hs-comment">--</span><span>
</span><span id="line-629"></span><span class="hs-comment">-- We have three kinds of calls: normal (CmmCall), safe foreign (CmmForeignCall)</span><span>
</span><span id="line-630"></span><span class="hs-comment">-- and unsafe foreign (CmmUnsafeForeignCall). We perform sinking pass after</span><span>
</span><span id="line-631"></span><span class="hs-comment">-- stack layout (see Note [Sinking after stack layout]) which leads to two</span><span>
</span><span id="line-632"></span><span class="hs-comment">-- invariants related to calls:</span><span>
</span><span id="line-633"></span><span class="hs-comment">--</span><span>
</span><span id="line-634"></span><span class="hs-comment">--   a) during stack layout phase all safe foreign calls are turned into</span><span>
</span><span id="line-635"></span><span class="hs-comment">--      unsafe foreign calls (see Note [Lower safe foreign calls]). This</span><span>
</span><span id="line-636"></span><span class="hs-comment">--      means that we will never encounter CmmForeignCall node when running</span><span>
</span><span id="line-637"></span><span class="hs-comment">--      sinking after stack layout</span><span>
</span><span id="line-638"></span><span class="hs-comment">--</span><span>
</span><span id="line-639"></span><span class="hs-comment">--   b) stack layout saves all variables live across a call on the stack</span><span>
</span><span id="line-640"></span><span class="hs-comment">--      just before making a call (remember we are not sinking assignments to</span><span>
</span><span id="line-641"></span><span class="hs-comment">--      stack):</span><span>
</span><span id="line-642"></span><span class="hs-comment">--</span><span>
</span><span id="line-643"></span><span class="hs-comment">--       L1:</span><span>
</span><span id="line-644"></span><span class="hs-comment">--          x = R1</span><span>
</span><span id="line-645"></span><span class="hs-comment">--          P64[Sp - 16] = L2</span><span>
</span><span id="line-646"></span><span class="hs-comment">--          P64[Sp - 8]  = x</span><span>
</span><span id="line-647"></span><span class="hs-comment">--          Sp = Sp - 16</span><span>
</span><span id="line-648"></span><span class="hs-comment">--          call f() returns L2</span><span>
</span><span id="line-649"></span><span class="hs-comment">--       L2:</span><span>
</span><span id="line-650"></span><span class="hs-comment">--</span><span>
</span><span id="line-651"></span><span class="hs-comment">--      We will attempt to sink { x = R1 } but we will detect conflict with</span><span>
</span><span id="line-652"></span><span class="hs-comment">--      { P64[Sp - 8]  = x } and hence we will drop { x = R1 } without even</span><span>
</span><span id="line-653"></span><span class="hs-comment">--      checking whether it conflicts with { call f() }. In this way we will</span><span>
</span><span id="line-654"></span><span class="hs-comment">--      never need to check any assignment conflicts with CmmCall. Remember</span><span>
</span><span id="line-655"></span><span class="hs-comment">--      that we still need to check for potential memory conflicts.</span><span>
</span><span id="line-656"></span><span class="hs-comment">--</span><span>
</span><span id="line-657"></span><span class="hs-comment">-- So the result is that we only need to worry about CmmUnsafeForeignCall nodes</span><span>
</span><span id="line-658"></span><span class="hs-comment">-- when checking conflicts (see Note [Unsafe foreign calls clobber caller-save registers]).</span><span>
</span><span id="line-659"></span><span class="hs-comment">-- This assumption holds only when we do sinking after stack layout. If we run</span><span>
</span><span id="line-660"></span><span class="hs-comment">-- it before stack layout we need to check for possible conflicts with all three</span><span>
</span><span id="line-661"></span><span class="hs-comment">-- kinds of calls. Our `conflicts` function does that by using a generic</span><span>
</span><span id="line-662"></span><span class="hs-comment">-- foldRegsDefd and foldRegsUsed functions defined in DefinerOfRegs and</span><span>
</span><span id="line-663"></span><span class="hs-comment">-- UserOfRegs typeclasses.</span><span>
</span><span id="line-664"></span><span class="hs-comment">--</span><span>
</span><span id="line-665"></span><span>
</span><span id="line-666"></span><span class="hs-comment">-- An abstraction of memory read or written.</span><span>
</span><span id="line-667"></span><span class="hs-keyword">data</span><span> </span><span id="AbsMem"><span class="annot"><a href="GHC.Cmm.Sink.html#AbsMem"><span class="hs-identifier hs-var">AbsMem</span></a></span></span><span>
</span><span id="line-668"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="NoMem"><span class="annot"><a href="GHC.Cmm.Sink.html#NoMem"><span class="hs-identifier hs-var">NoMem</span></a></span></span><span>            </span><span class="hs-comment">-- no memory accessed</span><span>
</span><span id="line-669"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="AnyMem"><span class="annot"><a href="GHC.Cmm.Sink.html#AnyMem"><span class="hs-identifier hs-var">AnyMem</span></a></span></span><span>           </span><span class="hs-comment">-- arbitrary memory</span><span>
</span><span id="line-670"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="HeapMem"><span class="annot"><a href="GHC.Cmm.Sink.html#HeapMem"><span class="hs-identifier hs-var">HeapMem</span></a></span></span><span>          </span><span class="hs-comment">-- definitely heap memory</span><span>
</span><span id="line-671"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="StackMem"><span class="annot"><a href="GHC.Cmm.Sink.html#StackMem"><span class="hs-identifier hs-var">StackMem</span></a></span></span><span>         </span><span class="hs-comment">-- definitely stack memory</span><span>
</span><span id="line-672"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="SpMem"><span class="annot"><a href="GHC.Cmm.Sink.html#SpMem"><span class="hs-identifier hs-var">SpMem</span></a></span></span><span>            </span><span class="hs-comment">-- &lt;size&gt;[Sp+n]</span><span>
</span><span id="line-673"></span><span>       </span><span class="hs-pragma">{-# UNPACK</span><span> </span><span class="hs-pragma">#-}</span><span> </span><span class="hs-glyph">!</span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>
</span><span id="line-674"></span><span>       </span><span class="hs-pragma">{-# UNPACK</span><span> </span><span class="hs-pragma">#-}</span><span> </span><span class="hs-glyph">!</span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>
</span><span id="line-675"></span><span>
</span><span id="line-676"></span><span class="hs-comment">-- Having SpMem is important because it lets us float loads from Sp</span><span>
</span><span id="line-677"></span><span class="hs-comment">-- past stores to Sp as long as they don't overlap, and this helps to</span><span>
</span><span id="line-678"></span><span class="hs-comment">-- unravel some long sequences of</span><span>
</span><span id="line-679"></span><span class="hs-comment">--    x1 = [Sp + 8]</span><span>
</span><span id="line-680"></span><span class="hs-comment">--    x2 = [Sp + 16]</span><span>
</span><span id="line-681"></span><span class="hs-comment">--    ...</span><span>
</span><span id="line-682"></span><span class="hs-comment">--    [Sp + 8]  = xi</span><span>
</span><span id="line-683"></span><span class="hs-comment">--    [Sp + 16] = xj</span><span>
</span><span id="line-684"></span><span class="hs-comment">--</span><span>
</span><span id="line-685"></span><span class="hs-comment">-- Note that SpMem is invalidated if Sp is changed, but the definition</span><span>
</span><span id="line-686"></span><span class="hs-comment">-- of 'conflicts' above handles that.</span><span>
</span><span id="line-687"></span><span>
</span><span id="line-688"></span><span class="hs-comment">-- ToDo: this won't currently fix the following commonly occurring code:</span><span>
</span><span id="line-689"></span><span class="hs-comment">--    x1 = [R1 + 8]</span><span>
</span><span id="line-690"></span><span class="hs-comment">--    x2 = [R1 + 16]</span><span>
</span><span id="line-691"></span><span class="hs-comment">--    ..</span><span>
</span><span id="line-692"></span><span class="hs-comment">--    [Hp - 8] = x1</span><span>
</span><span id="line-693"></span><span class="hs-comment">--    [Hp - 16] = x2</span><span>
</span><span id="line-694"></span><span class="hs-comment">--    ..</span><span>
</span><span id="line-695"></span><span>
</span><span id="line-696"></span><span class="hs-comment">-- because [R1 + 8] and [Hp - 8] are both HeapMem.  We know that</span><span>
</span><span id="line-697"></span><span class="hs-comment">-- assignments to [Hp + n] do not conflict with any other heap memory,</span><span>
</span><span id="line-698"></span><span class="hs-comment">-- but this is tricky to nail down.  What if we had</span><span>
</span><span id="line-699"></span><span class="hs-comment">--</span><span>
</span><span id="line-700"></span><span class="hs-comment">--   x = Hp + n</span><span>
</span><span id="line-701"></span><span class="hs-comment">--   [x] = ...</span><span>
</span><span id="line-702"></span><span class="hs-comment">--</span><span>
</span><span id="line-703"></span><span class="hs-comment">--  the store to [x] should be &quot;new heap&quot;, not &quot;old heap&quot;.</span><span>
</span><span id="line-704"></span><span class="hs-comment">--  Furthermore, you could imagine that if we started inlining</span><span>
</span><span id="line-705"></span><span class="hs-comment">--  functions in Cmm then there might well be reads of heap memory</span><span>
</span><span id="line-706"></span><span class="hs-comment">--  that was written in the same basic block.  To take advantage of</span><span>
</span><span id="line-707"></span><span class="hs-comment">--  non-aliasing of heap memory we will have to be more clever.</span><span>
</span><span id="line-708"></span><span>
</span><span id="line-709"></span><span class="hs-comment">-- Note [Foreign calls clobber heap]</span><span>
</span><span id="line-710"></span><span class="hs-comment">-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span><span>
</span><span id="line-711"></span><span class="hs-comment">--</span><span>
</span><span id="line-712"></span><span class="hs-comment">-- It is tempting to say that foreign calls clobber only</span><span>
</span><span id="line-713"></span><span class="hs-comment">-- non-heap/stack memory, but unfortunately we break this invariant in</span><span>
</span><span id="line-714"></span><span class="hs-comment">-- the RTS.  For example, in stg_catch_retry_frame we call</span><span>
</span><span id="line-715"></span><span class="hs-comment">-- stmCommitNestedTransaction() which modifies the contents of the</span><span>
</span><span id="line-716"></span><span class="hs-comment">-- TRec it is passed (this actually caused incorrect code to be</span><span>
</span><span id="line-717"></span><span class="hs-comment">-- generated).</span><span>
</span><span id="line-718"></span><span class="hs-comment">--</span><span>
</span><span id="line-719"></span><span class="hs-comment">-- Since the invariant is true for the majority of foreign calls,</span><span>
</span><span id="line-720"></span><span class="hs-comment">-- perhaps we ought to have a special annotation for calls that can</span><span>
</span><span id="line-721"></span><span class="hs-comment">-- modify heap/stack memory.  For now we just use the conservative</span><span>
</span><span id="line-722"></span><span class="hs-comment">-- definition here.</span><span>
</span><span id="line-723"></span><span class="hs-comment">--</span><span>
</span><span id="line-724"></span><span class="hs-comment">-- Some CallishMachOp imply a memory barrier e.g. AtomicRMW and</span><span>
</span><span id="line-725"></span><span class="hs-comment">-- therefore we should never float any memory operations across one of</span><span>
</span><span id="line-726"></span><span class="hs-comment">-- these calls.</span><span>
</span><span id="line-727"></span><span>
</span><span id="line-728"></span><span>
</span><span id="line-729"></span><span class="annot"><a href="GHC.Cmm.Sink.html#bothMems"><span class="hs-identifier hs-type">bothMems</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Sink.html#AbsMem"><span class="hs-identifier hs-type">AbsMem</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Sink.html#AbsMem"><span class="hs-identifier hs-type">AbsMem</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Sink.html#AbsMem"><span class="hs-identifier hs-type">AbsMem</span></a></span><span>
</span><span id="line-730"></span><span id="bothMems"><span class="annot"><span class="annottext">bothMems :: AbsMem -&gt; AbsMem -&gt; AbsMem
</span><a href="GHC.Cmm.Sink.html#bothMems"><span class="hs-identifier hs-var hs-var">bothMems</span></a></span></span><span> </span><span class="annot"><span class="annottext">AbsMem
</span><a href="GHC.Cmm.Sink.html#NoMem"><span class="hs-identifier hs-var">NoMem</span></a></span><span>    </span><span id="local-6989586621681045988"><span class="annot"><span class="annottext">AbsMem
</span><a href="#local-6989586621681045988"><span class="hs-identifier hs-var">x</span></a></span></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AbsMem
</span><a href="#local-6989586621681045988"><span class="hs-identifier hs-var">x</span></a></span><span>
</span><span id="line-731"></span><span class="annot"><a href="GHC.Cmm.Sink.html#bothMems"><span class="hs-identifier hs-var">bothMems</span></a></span><span> </span><span id="local-6989586621681045987"><span class="annot"><span class="annottext">AbsMem
</span><a href="#local-6989586621681045987"><span class="hs-identifier hs-var">x</span></a></span></span><span>        </span><span class="annot"><span class="annottext">AbsMem
</span><a href="GHC.Cmm.Sink.html#NoMem"><span class="hs-identifier hs-var">NoMem</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AbsMem
</span><a href="#local-6989586621681045987"><span class="hs-identifier hs-var">x</span></a></span><span>
</span><span id="line-732"></span><span class="annot"><a href="GHC.Cmm.Sink.html#bothMems"><span class="hs-identifier hs-var">bothMems</span></a></span><span> </span><span class="annot"><span class="annottext">AbsMem
</span><a href="GHC.Cmm.Sink.html#HeapMem"><span class="hs-identifier hs-var">HeapMem</span></a></span><span>  </span><span class="annot"><span class="annottext">AbsMem
</span><a href="GHC.Cmm.Sink.html#HeapMem"><span class="hs-identifier hs-var">HeapMem</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AbsMem
</span><a href="GHC.Cmm.Sink.html#HeapMem"><span class="hs-identifier hs-var">HeapMem</span></a></span><span>
</span><span id="line-733"></span><span class="annot"><a href="GHC.Cmm.Sink.html#bothMems"><span class="hs-identifier hs-var">bothMems</span></a></span><span> </span><span class="annot"><span class="annottext">AbsMem
</span><a href="GHC.Cmm.Sink.html#StackMem"><span class="hs-identifier hs-var">StackMem</span></a></span><span> </span><span class="annot"><span class="annottext">AbsMem
</span><a href="GHC.Cmm.Sink.html#StackMem"><span class="hs-identifier hs-var">StackMem</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AbsMem
</span><a href="GHC.Cmm.Sink.html#StackMem"><span class="hs-identifier hs-var">StackMem</span></a></span><span>
</span><span id="line-734"></span><span class="annot"><a href="GHC.Cmm.Sink.html#bothMems"><span class="hs-identifier hs-var">bothMems</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Sink.html#SpMem"><span class="hs-identifier hs-type">SpMem</span></a></span><span> </span><span id="local-6989586621681045986"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681045986"><span class="hs-identifier hs-var">o1</span></a></span></span><span> </span><span id="local-6989586621681045985"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681045985"><span class="hs-identifier hs-var">w1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Sink.html#SpMem"><span class="hs-identifier hs-type">SpMem</span></a></span><span> </span><span id="local-6989586621681045984"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681045984"><span class="hs-identifier hs-var">o2</span></a></span></span><span> </span><span id="local-6989586621681045983"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681045983"><span class="hs-identifier hs-var">w2</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-735"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681045986"><span class="hs-identifier hs-var">o1</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681045984"><span class="hs-identifier hs-var">o2</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; AbsMem
</span><a href="GHC.Cmm.Sink.html#SpMem"><span class="hs-identifier hs-var">SpMem</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681045986"><span class="hs-identifier hs-var">o1</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Ord a =&gt; a -&gt; a -&gt; a
</span><span class="hs-identifier hs-var">max</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681045985"><span class="hs-identifier hs-var">w1</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681045983"><span class="hs-identifier hs-var">w2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-736"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AbsMem
</span><a href="GHC.Cmm.Sink.html#StackMem"><span class="hs-identifier hs-var">StackMem</span></a></span><span>
</span><span id="line-737"></span><span class="annot"><a href="GHC.Cmm.Sink.html#bothMems"><span class="hs-identifier hs-var">bothMems</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Sink.html#SpMem"><span class="hs-identifier hs-type">SpMem</span></a></span><span class="hs-special">{</span><span class="hs-special">}</span><span>  </span><span class="annot"><span class="annottext">AbsMem
</span><a href="GHC.Cmm.Sink.html#StackMem"><span class="hs-identifier hs-var">StackMem</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AbsMem
</span><a href="GHC.Cmm.Sink.html#StackMem"><span class="hs-identifier hs-var">StackMem</span></a></span><span>
</span><span id="line-738"></span><span class="annot"><a href="GHC.Cmm.Sink.html#bothMems"><span class="hs-identifier hs-var">bothMems</span></a></span><span> </span><span class="annot"><span class="annottext">AbsMem
</span><a href="GHC.Cmm.Sink.html#StackMem"><span class="hs-identifier hs-var">StackMem</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Sink.html#SpMem"><span class="hs-identifier hs-type">SpMem</span></a></span><span class="hs-special">{</span><span class="hs-special">}</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AbsMem
</span><a href="GHC.Cmm.Sink.html#StackMem"><span class="hs-identifier hs-var">StackMem</span></a></span><span>
</span><span id="line-739"></span><span class="annot"><a href="GHC.Cmm.Sink.html#bothMems"><span class="hs-identifier hs-var">bothMems</span></a></span><span> </span><span class="annot"><span class="annottext">AbsMem
</span><span class="hs-identifier">_</span></span><span>         </span><span class="annot"><span class="annottext">AbsMem
</span><span class="hs-identifier">_</span></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AbsMem
</span><a href="GHC.Cmm.Sink.html#AnyMem"><span class="hs-identifier hs-var">AnyMem</span></a></span><span>
</span><span id="line-740"></span><span>
</span><span id="line-741"></span><span class="annot"><a href="GHC.Cmm.Sink.html#memConflicts"><span class="hs-identifier hs-type">memConflicts</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Sink.html#AbsMem"><span class="hs-identifier hs-type">AbsMem</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Sink.html#AbsMem"><span class="hs-identifier hs-type">AbsMem</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-742"></span><span id="memConflicts"><span class="annot"><span class="annottext">memConflicts :: AbsMem -&gt; AbsMem -&gt; Bool
</span><a href="GHC.Cmm.Sink.html#memConflicts"><span class="hs-identifier hs-var hs-var">memConflicts</span></a></span></span><span> </span><span class="annot"><span class="annottext">AbsMem
</span><a href="GHC.Cmm.Sink.html#NoMem"><span class="hs-identifier hs-var">NoMem</span></a></span><span>      </span><span class="annot"><span class="annottext">AbsMem
</span><span class="hs-identifier">_</span></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-743"></span><span class="annot"><a href="GHC.Cmm.Sink.html#memConflicts"><span class="hs-identifier hs-var">memConflicts</span></a></span><span> </span><span class="annot"><span class="annottext">AbsMem
</span><span class="hs-identifier">_</span></span><span>          </span><span class="annot"><span class="annottext">AbsMem
</span><a href="GHC.Cmm.Sink.html#NoMem"><span class="hs-identifier hs-var">NoMem</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-744"></span><span class="annot"><a href="GHC.Cmm.Sink.html#memConflicts"><span class="hs-identifier hs-var">memConflicts</span></a></span><span> </span><span class="annot"><span class="annottext">AbsMem
</span><a href="GHC.Cmm.Sink.html#HeapMem"><span class="hs-identifier hs-var">HeapMem</span></a></span><span>    </span><span class="annot"><span class="annottext">AbsMem
</span><a href="GHC.Cmm.Sink.html#StackMem"><span class="hs-identifier hs-var">StackMem</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-745"></span><span class="annot"><a href="GHC.Cmm.Sink.html#memConflicts"><span class="hs-identifier hs-var">memConflicts</span></a></span><span> </span><span class="annot"><span class="annottext">AbsMem
</span><a href="GHC.Cmm.Sink.html#StackMem"><span class="hs-identifier hs-var">StackMem</span></a></span><span>   </span><span class="annot"><span class="annottext">AbsMem
</span><a href="GHC.Cmm.Sink.html#HeapMem"><span class="hs-identifier hs-var">HeapMem</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-746"></span><span class="annot"><a href="GHC.Cmm.Sink.html#memConflicts"><span class="hs-identifier hs-var">memConflicts</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Sink.html#SpMem"><span class="hs-identifier hs-type">SpMem</span></a></span><span class="hs-special">{</span><span class="hs-special">}</span><span>    </span><span class="annot"><span class="annottext">AbsMem
</span><a href="GHC.Cmm.Sink.html#HeapMem"><span class="hs-identifier hs-var">HeapMem</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-747"></span><span class="annot"><a href="GHC.Cmm.Sink.html#memConflicts"><span class="hs-identifier hs-var">memConflicts</span></a></span><span> </span><span class="annot"><span class="annottext">AbsMem
</span><a href="GHC.Cmm.Sink.html#HeapMem"><span class="hs-identifier hs-var">HeapMem</span></a></span><span>    </span><span class="annot"><a href="GHC.Cmm.Sink.html#SpMem"><span class="hs-identifier hs-type">SpMem</span></a></span><span class="hs-special">{</span><span class="hs-special">}</span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-748"></span><span class="annot"><a href="GHC.Cmm.Sink.html#memConflicts"><span class="hs-identifier hs-var">memConflicts</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Sink.html#SpMem"><span class="hs-identifier hs-type">SpMem</span></a></span><span> </span><span id="local-6989586621681045981"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681045981"><span class="hs-identifier hs-var">o1</span></a></span></span><span> </span><span id="local-6989586621681045980"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681045980"><span class="hs-identifier hs-var">w1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Sink.html#SpMem"><span class="hs-identifier hs-type">SpMem</span></a></span><span> </span><span id="local-6989586621681045979"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681045979"><span class="hs-identifier hs-var">o2</span></a></span></span><span> </span><span id="local-6989586621681045978"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681045978"><span class="hs-identifier hs-var">w2</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-749"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681045981"><span class="hs-identifier hs-var">o1</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681045979"><span class="hs-identifier hs-var">o2</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681045981"><span class="hs-identifier hs-var">o1</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681045980"><span class="hs-identifier hs-var">w1</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681045979"><span class="hs-identifier hs-var">o2</span></a></span><span>
</span><span id="line-750"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681045979"><span class="hs-identifier hs-var">o2</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681045978"><span class="hs-identifier hs-var">w2</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681045981"><span class="hs-identifier hs-var">o1</span></a></span><span>
</span><span id="line-751"></span><span class="annot"><a href="GHC.Cmm.Sink.html#memConflicts"><span class="hs-identifier hs-var">memConflicts</span></a></span><span> </span><span class="annot"><span class="annottext">AbsMem
</span><span class="hs-identifier">_</span></span><span>         </span><span class="annot"><span class="annottext">AbsMem
</span><span class="hs-identifier">_</span></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-752"></span><span>
</span><span id="line-753"></span><span class="annot"><a href="GHC.Cmm.Sink.html#exprMem"><span class="hs-identifier hs-type">exprMem</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#Platform"><span class="hs-identifier hs-type">Platform</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Sink.html#AbsMem"><span class="hs-identifier hs-type">AbsMem</span></a></span><span>
</span><span id="line-754"></span><span id="exprMem"><span class="annot"><span class="annottext">exprMem :: Platform -&gt; CmmExpr -&gt; AbsMem
</span><a href="GHC.Cmm.Sink.html#exprMem"><span class="hs-identifier hs-var hs-var">exprMem</span></a></span></span><span> </span><span id="local-6989586621681045976"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681045976"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmLoad"><span class="hs-identifier hs-type">CmmLoad</span></a></span><span> </span><span id="local-6989586621681045974"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681045974"><span class="hs-identifier hs-var">addr</span></a></span></span><span> </span><span id="local-6989586621681045973"><span class="annot"><span class="annottext">CmmType
</span><a href="#local-6989586621681045973"><span class="hs-identifier hs-var">w</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AbsMem -&gt; AbsMem -&gt; AbsMem
</span><a href="GHC.Cmm.Sink.html#bothMems"><span class="hs-identifier hs-var">bothMems</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; CmmExpr -&gt; Width -&gt; AbsMem
</span><a href="GHC.Cmm.Sink.html#loadAddr"><span class="hs-identifier hs-var">loadAddr</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681045976"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681045974"><span class="hs-identifier hs-var">addr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmType -&gt; Width
</span><a href="GHC.Cmm.Type.html#typeWidth"><span class="hs-identifier hs-var">typeWidth</span></a></span><span> </span><span class="annot"><span class="annottext">CmmType
</span><a href="#local-6989586621681045973"><span class="hs-identifier hs-var">w</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; CmmExpr -&gt; AbsMem
</span><a href="GHC.Cmm.Sink.html#exprMem"><span class="hs-identifier hs-var">exprMem</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681045976"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681045974"><span class="hs-identifier hs-var">addr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-755"></span><span class="annot"><a href="GHC.Cmm.Sink.html#exprMem"><span class="hs-identifier hs-var">exprMem</span></a></span><span> </span><span id="local-6989586621681045971"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681045971"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmMachOp"><span class="hs-identifier hs-type">CmmMachOp</span></a></span><span> </span><span class="annot"><span class="annottext">MachOp
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681045970"><span class="annot"><span class="annottext">[CmmExpr]
</span><a href="#local-6989586621681045970"><span class="hs-identifier hs-var">es</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(AbsMem -&gt; AbsMem -&gt; AbsMem) -&gt; AbsMem -&gt; [AbsMem] -&gt; AbsMem
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="annot"><span class="annottext">AbsMem -&gt; AbsMem -&gt; AbsMem
</span><a href="GHC.Cmm.Sink.html#bothMems"><span class="hs-identifier hs-var">bothMems</span></a></span><span> </span><span class="annot"><span class="annottext">AbsMem
</span><a href="GHC.Cmm.Sink.html#NoMem"><span class="hs-identifier hs-var">NoMem</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(CmmExpr -&gt; AbsMem) -&gt; [CmmExpr] -&gt; [AbsMem]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; CmmExpr -&gt; AbsMem
</span><a href="GHC.Cmm.Sink.html#exprMem"><span class="hs-identifier hs-var">exprMem</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681045971"><span class="hs-identifier hs-var">platform</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[CmmExpr]
</span><a href="#local-6989586621681045970"><span class="hs-identifier hs-var">es</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-756"></span><span class="annot"><a href="GHC.Cmm.Sink.html#exprMem"><span class="hs-identifier hs-var">exprMem</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><span class="hs-identifier">_</span></span><span>        </span><span class="annot"><span class="annottext">CmmExpr
</span><span class="hs-identifier">_</span></span><span>                 </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AbsMem
</span><a href="GHC.Cmm.Sink.html#NoMem"><span class="hs-identifier hs-var">NoMem</span></a></span><span>
</span><span id="line-757"></span><span>
</span><span id="line-758"></span><span class="annot"><a href="GHC.Cmm.Sink.html#loadAddr"><span class="hs-identifier hs-type">loadAddr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#Platform"><span class="hs-identifier hs-type">Platform</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Type.html#Width"><span class="hs-identifier hs-type">Width</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Sink.html#AbsMem"><span class="hs-identifier hs-type">AbsMem</span></a></span><span>
</span><span id="line-759"></span><span id="loadAddr"><span class="annot"><span class="annottext">loadAddr :: Platform -&gt; CmmExpr -&gt; Width -&gt; AbsMem
</span><a href="GHC.Cmm.Sink.html#loadAddr"><span class="hs-identifier hs-var hs-var">loadAddr</span></a></span></span><span> </span><span id="local-6989586621681045969"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681045969"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span id="local-6989586621681045968"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681045968"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span id="local-6989586621681045967"><span class="annot"><span class="annottext">Width
</span><a href="#local-6989586621681045967"><span class="hs-identifier hs-var">w</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-760"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681045968"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-761"></span><span>   </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmReg"><span class="hs-identifier hs-type">CmmReg</span></a></span><span> </span><span id="local-6989586621681045966"><span class="annot"><span class="annottext">CmmReg
</span><a href="#local-6989586621681045966"><span class="hs-identifier hs-var">r</span></a></span></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; CmmReg -&gt; Int -&gt; Width -&gt; AbsMem
</span><a href="GHC.Cmm.Sink.html#regAddr"><span class="hs-identifier hs-var">regAddr</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681045969"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReg
</span><a href="#local-6989586621681045966"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">Width
</span><a href="#local-6989586621681045967"><span class="hs-identifier hs-var">w</span></a></span><span>
</span><span id="line-762"></span><span>   </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmRegOff"><span class="hs-identifier hs-type">CmmRegOff</span></a></span><span> </span><span id="local-6989586621681045964"><span class="annot"><span class="annottext">CmmReg
</span><a href="#local-6989586621681045964"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span id="local-6989586621681045963"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681045963"><span class="hs-identifier hs-var">i</span></a></span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; CmmReg -&gt; Int -&gt; Width -&gt; AbsMem
</span><a href="GHC.Cmm.Sink.html#regAddr"><span class="hs-identifier hs-var">regAddr</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681045969"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReg
</span><a href="#local-6989586621681045964"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681045963"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="annot"><span class="annottext">Width
</span><a href="#local-6989586621681045967"><span class="hs-identifier hs-var">w</span></a></span><span>
</span><span id="line-763"></span><span>   </span><span id="local-6989586621681045962"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681045962"><span class="hs-identifier hs-var">_other</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; CmmReg -&gt; CmmExpr -&gt; Bool
</span><a href="GHC.Cmm.Utils.html#regUsedIn"><span class="hs-identifier hs-var">regUsedIn</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681045969"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReg
</span><a href="GHC.Cmm.Expr.html#spReg"><span class="hs-identifier hs-var">spReg</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681045968"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">AbsMem
</span><a href="GHC.Cmm.Sink.html#StackMem"><span class="hs-identifier hs-var">StackMem</span></a></span><span>
</span><span id="line-764"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">AbsMem
</span><a href="GHC.Cmm.Sink.html#AnyMem"><span class="hs-identifier hs-var">AnyMem</span></a></span><span>
</span><span id="line-765"></span><span>
</span><span id="line-766"></span><span class="annot"><a href="GHC.Cmm.Sink.html#regAddr"><span class="hs-identifier hs-type">regAddr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#Platform"><span class="hs-identifier hs-type">Platform</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmReg"><span class="hs-identifier hs-type">CmmReg</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Type.html#Width"><span class="hs-identifier hs-type">Width</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Sink.html#AbsMem"><span class="hs-identifier hs-type">AbsMem</span></a></span><span>
</span><span id="line-767"></span><span id="regAddr"><span class="annot"><span class="annottext">regAddr :: Platform -&gt; CmmReg -&gt; Int -&gt; Width -&gt; AbsMem
</span><a href="GHC.Cmm.Sink.html#regAddr"><span class="hs-identifier hs-var hs-var">regAddr</span></a></span></span><span> </span><span class="annot"><span class="annottext">Platform
</span><span class="hs-identifier">_</span></span><span>      </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmGlobal"><span class="hs-identifier hs-type">CmmGlobal</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalReg
</span><a href="GHC.Cmm.Expr.html#Sp"><span class="hs-identifier hs-var">Sp</span></a></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681045960"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681045960"><span class="hs-identifier hs-var">i</span></a></span></span><span> </span><span id="local-6989586621681045959"><span class="annot"><span class="annottext">Width
</span><a href="#local-6989586621681045959"><span class="hs-identifier hs-var">w</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; AbsMem
</span><a href="GHC.Cmm.Sink.html#SpMem"><span class="hs-identifier hs-var">SpMem</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681045960"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Width -&gt; Int
</span><a href="GHC.Cmm.Type.html#widthInBytes"><span class="hs-identifier hs-var">widthInBytes</span></a></span><span> </span><span class="annot"><span class="annottext">Width
</span><a href="#local-6989586621681045959"><span class="hs-identifier hs-var">w</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-768"></span><span class="annot"><a href="GHC.Cmm.Sink.html#regAddr"><span class="hs-identifier hs-var">regAddr</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><span class="hs-identifier">_</span></span><span>      </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmGlobal"><span class="hs-identifier hs-type">CmmGlobal</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalReg
</span><a href="GHC.Cmm.Expr.html#Hp"><span class="hs-identifier hs-var">Hp</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Width
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AbsMem
</span><a href="GHC.Cmm.Sink.html#HeapMem"><span class="hs-identifier hs-var">HeapMem</span></a></span><span>
</span><span id="line-769"></span><span class="annot"><a href="GHC.Cmm.Sink.html#regAddr"><span class="hs-identifier hs-var">regAddr</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><span class="hs-identifier">_</span></span><span>      </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmGlobal"><span class="hs-identifier hs-type">CmmGlobal</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalReg
</span><a href="GHC.Cmm.Expr.html#CurrentTSO"><span class="hs-identifier hs-var">CurrentTSO</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Width
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AbsMem
</span><a href="GHC.Cmm.Sink.html#HeapMem"><span class="hs-identifier hs-var">HeapMem</span></a></span><span> </span><span class="hs-comment">-- important for PrimOps</span><span>
</span><span id="line-770"></span><span class="annot"><a href="GHC.Cmm.Sink.html#regAddr"><span class="hs-identifier hs-var">regAddr</span></a></span><span> </span><span id="local-6989586621681045956"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681045956"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span id="local-6989586621681045955"><span class="annot"><span class="annottext">CmmReg
</span><a href="#local-6989586621681045955"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Width
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CmmType -&gt; Bool
</span><a href="GHC.Cmm.Type.html#isGcPtrType"><span class="hs-identifier hs-var">isGcPtrType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; CmmReg -&gt; CmmType
</span><a href="GHC.Cmm.Expr.html#cmmRegType"><span class="hs-identifier hs-var">cmmRegType</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681045956"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReg
</span><a href="#local-6989586621681045955"><span class="hs-identifier hs-var">r</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AbsMem
</span><a href="GHC.Cmm.Sink.html#HeapMem"><span class="hs-identifier hs-var">HeapMem</span></a></span><span> </span><span class="hs-comment">-- yay! GCPtr pays for itself</span><span>
</span><span id="line-771"></span><span class="annot"><a href="GHC.Cmm.Sink.html#regAddr"><span class="hs-identifier hs-var">regAddr</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><span class="hs-identifier">_</span></span><span>      </span><span class="annot"><span class="annottext">CmmReg
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Width
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AbsMem
</span><a href="GHC.Cmm.Sink.html#AnyMem"><span class="hs-identifier hs-var">AnyMem</span></a></span><span>
</span><span id="line-772"></span><span>
</span><span id="line-773"></span><span class="hs-comment">{-
Note [Inline GlobalRegs?]
~~~~~~~~~~~~~~~~~~~~~~~~~

Should we freely inline GlobalRegs?

Actually it doesn't make a huge amount of difference either way, so we
*do* currently treat GlobalRegs as &quot;trivial&quot; and inline them
everywhere, but for what it's worth, here is what I discovered when I
(SimonM) looked into this:

Common sense says we should not inline GlobalRegs, because when we
have

  x = R1

the register allocator will coalesce this assignment, generating no
code, and simply record the fact that x is bound to $rbx (or
whatever).  Furthermore, if we were to sink this assignment, then the
range of code over which R1 is live increases, and the range of code
over which x is live decreases.  All things being equal, it is better
for x to be live than R1, because R1 is a fixed register whereas x can
live in any register.  So we should neither sink nor inline 'x = R1'.

However, not inlining GlobalRegs can have surprising
consequences. e.g. (cgrun020)

  c3EN:
      _s3DB::P64 = R1;
      _c3ES::P64 = _s3DB::P64 &amp; 7;
      if (_c3ES::P64 &gt;= 2) goto c3EU; else goto c3EV;
  c3EU:
      _s3DD::P64 = P64[_s3DB::P64 + 6];
      _s3DE::P64 = P64[_s3DB::P64 + 14];
      I64[Sp - 8] = c3F0;
      R1 = _s3DE::P64;
      P64[Sp] = _s3DD::P64;

inlining the GlobalReg gives:

  c3EN:
      if (R1 &amp; 7 &gt;= 2) goto c3EU; else goto c3EV;
  c3EU:
      I64[Sp - 8] = c3F0;
      _s3DD::P64 = P64[R1 + 6];
      R1 = P64[R1 + 14];
      P64[Sp] = _s3DD::P64;

but if we don't inline the GlobalReg, instead we get:

      _s3DB::P64 = R1;
      if (_s3DB::P64 &amp; 7 &gt;= 2) goto c3EU; else goto c3EV;
  c3EU:
      I64[Sp - 8] = c3F0;
      R1 = P64[_s3DB::P64 + 14];
      P64[Sp] = P64[_s3DB::P64 + 6];

This looks better - we managed to inline _s3DD - but in fact it
generates an extra reg-reg move:

.Lc3EU:
        movq $c3F0_info,-8(%rbp)
        movq %rbx,%rax
        movq 14(%rbx),%rbx
        movq 6(%rax),%rax
        movq %rax,(%rbp)

because _s3DB is now live across the R1 assignment, we lost the
benefit of coalescing.

Who is at fault here?  Perhaps if we knew that _s3DB was an alias for
R1, then we would not sink a reference to _s3DB past the R1
assignment.  Or perhaps we *should* do that - we might gain by sinking
it, despite losing the coalescing opportunity.

Sometimes not inlining global registers wins by virtue of the rule
about not inlining into arguments of a foreign call, e.g. (T7163) this
is what happens when we inlined F1:

      _s3L2::F32 = F1;
      _c3O3::F32 = %MO_F_Mul_W32(F1, 10.0 :: W32);
      (_s3L7::F32) = call &quot;ccall&quot; arg hints:  []  result hints:  [] rintFloat(_c3O3::F32);

but if we don't inline F1:

      (_s3L7::F32) = call &quot;ccall&quot; arg hints:  []  result hints:  [] rintFloat(%MO_F_Mul_W32(_s3L2::F32,
                                                                                            10.0 :: W32));
-}</span><span>
</span><span id="line-861"></span></pre></body></html>